作者 qazsd (天際線)
標題 [請益] 使用Nginx顯示找不到檔案
時間 Tue Nov 28 22:25:21 2023


請教版上大大,小弟使用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)

請問是否有大大能夠指點迷津?
感謝

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 106.1.232.104 (臺灣)
※ 作者: qazsd 2023-11-28 22:25:21
※ 文章代碼(AID): #1bPVXMMk (Soft_Job)
※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1701181526.A.5AE.html
※ 編輯: qazsd (106.1.232.104 臺灣), 11/28/2023 23:04:46
B0988698088: 自己作業1F 11/28 23:15
layer0930: 先把網路基本學好…2F 11/29 01:45
MoonCode: 可以問llm3F 11/29 04:51
tsaigi: ???4F 11/29 08:39
surimodo: 看無5F 11/29 10:21
taitzyhwan: 可以問chatgpt6F 11/29 10:30
kurtsgm: https://i.imgur.com/LCX3cF7.png
我問copilot的 不用謝7F 11/29 11:31
[圖]
godddddd: 呃呃 找個可以檢查錯字的9F 11/29 16:14

--
作者 qazsd 的最新發文:
點此顯示更多發文記錄