开发者社区> 问答> 正文

nginx 做反向代理,到当前服务器的其他端口,有时候能访问,刷新一下就不行了

已解决

server { listen 80 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default;

    #error_page   404   /404.html;

    # Deny access to PHP files in specific directory
    #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

    include enable-php.conf;
    location /nginx_status
    {
        stub_status on;
        access_log   off;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;
    }

    location ~ /.well-known {
        allow all;
    }

    location ~ /\.
    {
        deny all;
    }

    access_log  /home/wwwlogs/access.log;
}

server { listen 80; server_name dis.zhujiao.world; location / { proxy_pass http://***********:8002;

proxy_redirect     off;
#proxy_cache cache_one;
   	 proxy_set_header   Host             $host;
    	proxy_set_header   X-Real-IP        $remote_addr;
   	 proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    	proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
    	proxy_max_temp_file_size 0;
}

}

展开
收起
游客te2u7qsxelpx4 2020-10-15 11:35:42 6993 0
2 条回答
写回答
取消 提交回答
  • 采纳回答

    listen 80 default_server reuseport;把这一行改成listen 80; 把后面那段删掉,然后Kill掉占用80端口的所有进程,再重启Nginx就行了,我自己慢慢摸索出来的,不知道对不对,我的问题是解决了

    2020-10-30 14:55:30
    赞同 展开评论 打赏
  • 无知人生,记录点滴。 不积跬步,无以至千里;不积小流,无以成江海 订阅号:微wx笑, 个人站点:https://www.ivu4e.cn/,https://www.ivu4e.com/ CSDN博客:https://blog.csdn.net/testcs_dn

    查看/home/wwwlogs/下面的日志内容,访问日志错误日志

    2020-10-15 11:41:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS快储存加密技术 立即下载