Nginx

nginx反向代理顯示預設頁面

  • August 28, 2022

我剛剛在我的 VPS 上安裝了 Synapse,現在嘗試設置 nginx 反向代理。但是,它顯示的是 nginx 預設頁面。我在https://discourse.xinghaizhandui.com>有另一個帶有反向代理的子域,它工作正常。我檢查了配置文件,但沒有看到反向代理不工作的任何原因<https://matrix.xinghaizhandui.com。有什麼想法嗎?如果我使用 SSH 隧道訪問 http://localhost:8008,則會載入正確的頁面。附件是matrix.conf。

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;

server_name matrix.xinghaizhandui.com;

location ~ ^(/_matrix|/_synapse/client) {
   proxy_pass http://localhost:8008;
   proxy_set_header Host $http_host;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   client_max_body_size 50M;
}
ssl_certificate /etc/letsencrypt/live/xinghaizhandui.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xinghaizhandui.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

嘗試這個

...
location / {
   proxy_pass http://localhost:8008;
...

引用自:https://serverfault.com/questions/1109290