Nginx 很糟糕

问题描述 投票:0回答:1

如果我访问我的网站,https://generalkenobi2.duckdns.org/files它将无法找到它并重定向到http://generalkenobi2.duckdns.org:81/files/这是错误的。我什至没有在端口 81 上监听外部,我的 apache 服务器在内部使用端口 81。但是,如果我向域添加正斜杠并删除端口,则它可以正常工作。其他前锋在有或没有尾部斜杠的情况下似乎都可以工作,为什么会有所不同?

附配置。

https://pastebin.pl/view/cbffea19

附视频。

https://imgur.com/a/JIB1SDV

我尝试为 /files/ 和 /files 添加一个,但结果是相同的。

linux apache nginx
1个回答
0
投票

此问题可能源于您的反向代理如何设置来处理对

/files
的请求,以及这些请求在传递到在端口 81 上运行的内部 Apache 服务器之前如何解释或重写:

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name generalkenobi2.duckdns.org;

  ssl_certificate /etc/letsencrypt/live/npm-4/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-4/privkey.pem;

  location /files {
    proxy_pass http://192.168.51.8:81;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.