原来的 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" "-"
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于