V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
gogobody
V2EX  ›  问与答

请教 nginx 反向代理问题

  •  
  •   gogobody · Apr 4, 2020 · 2120 views
    This topic created in 2223 days ago, the information mentioned may be changed or developed.

    描述如下: https 反向代理到 http 网站。

    docker 运行网站 A,端口映射为 8003=>80, 8443=>443

    域名 www.test 绑定主机 8003 端口,加上 https 证书。

    问题:

    http://www.test 访问一切正常,https://www.test 访问页面正常,登录 post 请求时,第一次登录返回状态码 200,response:failed to load response data 。第二次登录 post 返回正常,之后登录就正常了。

    nginx 反向代理配置如下:

    
    location / 
    {
        proxy_pass http://homeland;
        proxy_redirect off;
        proxy_set_header Host MYDOMAIN;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
        add_header X-Cache $upstream_cache_status;
        
        proxy_redirect  http://0.0.0.0:8003 https://MYDOMAIN;
        #Set Nginx Cache
        
        add_header Cache-Control no-cache;
        expires 12h;
        
    }
    
    
    Supplement 1  ·  Apr 5, 2020
    第二次原来是上一次点击登录后给跳转到 http,所以才登录成功 = =
    Supplement 2  ·  Apr 5, 2020
    强制跳转到 https 之后发现无法登录了 0 0
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5776 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 03:45 · PVG 11:45 · LAX 20:45 · JFK 23:45
    ♥ Do have faith in what you're doing.