请教版上大大,小弟使用Nginx来转发两个web service请求,其设定如下
server {
listen 80;
listen 1000;
server_name 192.168.1.150;
return 301 https://for_test.net$request_uri;
}
server {
listen 2000;
server_name 192.168.1.150;
return 301 https://for_test.net/forms$request_uri;
}
server {
listen 443 ssl;
server_name for_test.net;
ssl_certificate /etc/nginx/ssl/certs/for_test.crt;
ssl_certificate_key /etc/nginx/ssl/private/for_test.key;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers
'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
add_header Strict-Transport-Security "max-age=31536000" always;
### A PyWebIO web service ###
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Photo $scheme;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
}
### A Streamlit web service ###
location /form {
proxy_pass http://127.0.0.1:4000/;
alias /home/streamlit_app/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Photo $scheme;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
已知连线到http://192.168.1.150时会成功转到 https://for_test.net
但是连线到http://192.168.1.150/form时,则会显示Connection error
http://192.168.1.150/form对应的是使用Streamlit制作的web service
其错误似乎是找不到档案 (HTTP 404,非HTTP 301)
请问是否有大大能够指点迷津?
感谢