Nginx 重定向到后端-nginx 服务器返回错误的端口

时间:2020-12-20 22:53:52

标签: docker nginx

我正在处理一些 docker 容器,其中有一个“主”nginx 主机,然后代理到其他 nginx 主机

server {
    listen 80;
    server_name mcaq.me www.mcaq.me files.mcaq.me dev.mcaq.me priv.mcaq.me;

    location / {
        proxy_pass http://mcaq:8080;
        proxy_redirect http://mcaq:8080/;
        proxy_set_header    Host                   $http_host;
        proxy_set_header    X-Real-IP              $remote_addr;
        proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto      $scheme;
    }
}

这个(上图)是主要的nginx容器

server {
    listen 8080;
    index index.html index.php;
    server_name mcaq.me www.mcaq.me;
    root /code;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass localhost:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

这个(上图)是一个子nginx容器的例子 运行后主要的nginx服务器被certbot控制,所以实际上是在443 ssl上监听 连接到 https://mcaq.me/ 时,这与我预期的一样 然后,当去https://mcaq.me/portfolio时,它打破

显示的是8080端口,看不懂 如果你改为https://mcaq.me/portfolio/ 它按预期工作 我尝试了不同的方法,例如使用 proxy_redirect,但我正在努力寻找解决方案,或了解问题所在 任何建议,或者如果您需要更多信息,请告诉我。干杯!

0 个答案:

没有答案
相关问题