V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
tyhunter
V2EX  ›  问与答

求教关于 Nginx 二级域名反向代理“端口/目录”的模式该怎么设置

  •  
  •   tyhunter · 2019-06-17 10:42:18 +08:00 · 1526 次点击
    这是一个创建于 1768 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前存在一个服务,完整地址为: http://xx.xx.xx.xx:6000/admin/,打开需要 HTTP 验证
    想要通过 Nginx 用二级域名反向代理为: http://file.xxxxx.com/
    通过在 /etc/nginx/sites-enabled 新建一个 file 的文件,内容为:
    server {
    listen 80;

    server_name file.xxxxx.com;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 10G;

    location / {
    proxy_pass http://localhost:6000/admin/;
    proxy_set_header X-Forwarded-For ;
    proxy_set_header Host ;
    proxy_set_header X-Forwarded-Proto ;
    proxy_buffering off;
    }
    }

    发现打开 http://file.xxxxx.com 会弹出 HTTP 验证窗口,但是输入正确的用户名和密码后,页面一直是空白的状态
    不知道是不是转发没有配置好,导致了只反向代理了部分内容,求教下大神们该怎么才能正确设置
    5 条回复    2019-06-17 23:35:51 +08:00
    Belmode
        1
    Belmode  
       2019-06-17 11:18:38 +08:00 via Android   ❤️ 1
    proxy_set_header Host $host
    tyhunter
        2
    tyhunter  
    OP
       2019-06-17 11:38:33 +08:00
    @Belmode #1 试了 $host; 、$http_host; 、$host:$proxy_port;
    结果都一样是通过 HTTP 验证后页面空白
    dream10201
        3
    dream10201  
       2019-06-17 14:21:24 +08:00   ❤️ 1
    include proxy_params;
    加上后试一遍,不行再试着把 http://localhost:6000/admin/;改为 http://localhost:6000/admin;
    Latin
        4
    Latin  
       2019-06-17 14:40:54 +08:00 via iPhone
    为啥前置非得到 admin 直接到 server 的根目录啊
    mnssbe
        5
    mnssbe  
       2019-06-17 23:35:51 +08:00
    f12 看一下 估计路径有问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5017 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:48 · PVG 11:48 · LAX 20:48 · JFK 23:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.