solo 迁移后 nginx 502

原来的 VPS 到期了,换了一家,近期在做迁移时,nginx 代理出现 502,很奇怪,配置文件和脚本都是一样的,域名切回到原来的 IP 就好使,新的 IP,solo 不行,通过 IP 直接访问页面是乱的。

solo 的启动脚本:

docker pull b3log/solo
docker stop solo
docker rm solo
docker run --detach --name solo --network=host \
    --env RUNTIME_DB="MYSQL" \
    --env JDBC_USERNAME="root" \
    --env JDBC_PASSWORD="123456789" \
    --env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
    --env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" \
    b3log/solo --listen_port=8080 --server_scheme=https --server_host=www.xiaoyver.top

solo 日志:

[INFO ]-[2020-10-21 11:03:41]-[org.b3log.solo.Server:253]: Solo is booting [ver=4.3.1, os=Linux, isDocker=true, inJar=false, luteAvailable=false, pid=1, runtimeDatabase=MYSQL, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC]
[INFO ]-[2020-10-21 11:03:42]-[org.b3log.solo.util.Skins:70]: Loaded template from directory [/opt/solo/]
[INFO ]-[2020-10-21 11:03:43]-[org.b3log.solo.Server:300]: Solo is running
[INFO ]-[2020-10-21 11:03:57]-[org.b3log.solo.service.ExportService:338]: Backup all articles to HacPai....
[INFO ]-[2020-10-21 11:04:00]-[org.b3log.solo.service.ExportService:394]: Backup all articles to HacPai completed: {"msg":"","code":0}
[INFO ]-[2020-10-21 11:04:00]-[org.b3log.solo.service.ExportService:271]: Backup public articles to your GitHub repo [solo-blog]....
[INFO ]-[2020-10-21 11:04:08]-[org.b3log.solo.service.ExportService:317]: Exported public articles to your repo [solo-blog]

nginx 的配置文件:/etc/nginx/conf.d/default.conf

upstream backend {
    server localhost:8080; # Tomcat/Jetty  原有的监听
}

server {
    listen       80;
    server_name  xiaoyver.top www.xiaoyver.top;

    access_log off;

        return 301 https://$server_name$request_uri;  # 监听80端口,并将server_name全部转发
}

server {
    listen       443	ssl;  # 修改监听接口
    server_name  xiaoyver.top www.xiaoyver.top;
    charset utf8; # 修改默认字符
    # ssl on;  # 开启ssl

    # 很重要!!!设定你的ssl证书
    ssl_certificate /etc/nginx/conf.d/1_www.xiaoyver.top_bundle.crt;
    ssl_certificate_key /etc/nginx/conf.d/2_www.xiaoyver.top.key;

    # 重要! 原有的接口代理可以不用修改,在内部使用http
    location / {
        proxy_pass http://backend$request_uri;
        proxy_set_header  Host $host:$server_port;
        proxy_set_header  X-Real-IP  $remote_addr;
        client_max_body_size  10m;
    }

    location /jianli {

        root   /usr/share/nginx/html;    #指定容器中的路径
        index  index.html index.htm;
    }

    location /daojishi {

        root   /usr/share/nginx/html;    #指定容器中的路径
        index  index.html index.htm;
    }
}

nginx 日志:

42.48.60.146 - - [21/Oct/2020:11:34:05 +0800] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43" "-"
42.48.60.146 - - [21/Oct/2020:11:34:05 +0800] "GET /favicon.ico HTTP/1.1" 502 559 "https://www.xiaoyver.top/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43" "-"
42.48.60.146 - - [21/Oct/2020:11:34:05 +0800] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43" "-"
42.48.60.146 - - [21/Oct/2020:11:34:05 +0800] "GET /favicon.ico HTTP/1.1" 502 559 "https://www.xiaoyver.top/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36 Edg/86.0.622.43" "-"

  • Solo

    Solo 是一款小而美的开源博客系统,专为程序员设计。Solo 有着非常活跃的社区,可将文章作为帖子推送到社区,来自社区的回帖将作为博客评论进行联动(具体细节请浏览 B3log 构思 - 分布式社区网络)。

    这是一种全新的网络社区体验,让热爱记录和分享的你不再感到孤单!

    1270 引用 • 9533 回帖 • 599 关注
  • NGINX

    NGINX 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 NGINX 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本 0.1.0 发布于 2004 年 10 月 4 日。

    276 引用 • 533 回帖 • 520 关注
  • 异常
    19 引用 • 47 回帖
  • Q&A

    提问之前请先看《提问的智慧》,好的问题比好的答案更有价值。

    1846 引用 • 11887 回帖 • 569 关注
2 操作
Xiaoyver 在 2020-10-21 12:49:40 更新了该帖
Xiaoyver 在 2020-10-21 12:29:24 更新了该帖

赞助商 我要投放

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...
  • Xiaoyver
    作者

    把各种服务停了,单独访问时发现 nginx 有以下错误

    2020/10/21 15:20:26 [crit] 17498#17498: *1 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: 110.53.177.181, server: xiaoyver.top, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "www.xiaoyver.top"
    2020/10/21 15:20:26 [warn] 17498#17498: *1 upstream server temporarily disabled while connecting to upstream, client: 110.53.177.181, server: xiaoyver.top, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "www.xiaoyver.top"
    2020/10/21 15:20:26 [crit] 17498#17498: *1 connect() to [::1]:8080 failed (13: Permission denied) while connecting to upstream, client: 110.53.177.181, server: xiaoyver.top, request: "GET / HTTP/1.1", upstream: "http://[::1]:8080/", host: "www.xiaoyver.top"
    2020/10/21 15:20:26 [warn] 17498#17498: *1 upstream server temporarily disabled while connecting to upstream, client: 110.53.177.181, server: xiaoyver.top, request: "GET / HTTP/1.1", upstream: "http://[::1]:8080/", host: "www.xiaoyver.top"
    
    

    解决方式:

    setsebool -P httpd_can_network_connect 1