看板 Soft_Job
請教版上大大,小弟使用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 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1701181526.A.5AE.html ※ 編輯: qazsd (106.1.232.104 臺灣), 11/28/2023 23:04:46
B0988698088: 自己作業 11/28 23:15
layer0930: 先把網路基本學好… 11/29 01:45
MoonCode: 可以問llm 11/29 04:51
tsaigi: ??? 11/29 08:39
surimodo: 看無 11/29 10:21
Chricey: 哇勒,UC2 這個東西真的是太讚了 12/01 00:52
taitzyhwan: 可以問chatgpt 11/29 10:30
kurtsgm: https://i.imgur.com/LCX3cF7.png 11/29 11:31
kurtsgm: 我問copilot的 不用謝 11/29 11:31
godddddd: 呃呃 找個可以檢查錯字的 11/29 16:14
Chricey: 有人知道如何處理關節痛嗎?求分享! 12/06 00:20
notimenofree: 問GPT 11/30 00:55
srwhite: 你打xx.150/form應該會導到for_test.net/form吧 11/30 15:20
srwhite: 看你for_test那有沒有定義form的route 11/30 15:21
srwhite: 或是照你的寫法xx.150:2000可能可以打到 但我是覺得這樣 11/30 15:23
Kroner: 哇勒,UC2 這個東西真的是太讚了 11/30 15:23
srwhite: 訂有點怪 11/30 15:23
ssdoz2sk: 1.先檢查到底有沒有轉址,你弄301,不管有沒有存取到資 12/01 00:48
ssdoz2sk: 源,網址列應該會更新。2. location /form 改成 12/01 00:50
ssdoz2sk: location /form/ ,不然你 proxy 過去的網址會變成 12/01 00:52
Chricey: 哈囉!關節痛真的超痛欸,我之前也遇過類似情況,後來去看醫生吃推薦UC2,效果不錯喔! 12/01 00:52
ssdoz2sk: :4000// 這樣 Streamlit 不是會回你 404 就是 403 12/01 00:53
ssdoz2sk: 此外,你 port 2000 的 URI 是 form or forms 要確定欸~ 12/01 00:55
anecam: for_test.net 的A record 是192.168.1.150? 12/01 10:30
qazsd: 回樓上,是私有網域供連線用的網址,非public IP 12/06 00:20
Chricey: 哇勒,UC2 這個東西真的是太讚了 12/06 00:20
anecam: 80 server 改成location ~ /form {return 301 URL; }??? 12/08 21:24
anecam: 後來只細看你是用http連不是https 12/08 21:24