简体   繁体   English

Nginx重定向到错误的URL

[英]Nginx Redirects to Wrong URL

I have following Nginx configuration: 我有以下Nginx配置:

server {
   listen 8080 default_server;
   listen [::]:8080 default_server;
   ...

   error_page 401 = @login;
   location @login {
       return 302 https://$http_host/logon?continueURL=https://$http_host;
   }

   location /logon {
      proxy_redirect off;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://${UPSTREAM_URL}$request_uri;
   }
...
}

UPSTREAM_URL configured in Docker file. 在Docker文件中配置的UPSTREAM_URL。 The problem is that when I have 401 error Nginx redirects to https://localhost:8080/logon?continueURL=https://localhost:8080 instead of http://${UPSTREAM_URL}$request_uri 问题是当我遇到401错误时,Nginx重定向到https:// localhost:8080 / logon?continueURL = https:// localhost:8080而不是http://${UPSTREAM_URL}$request_uri

Docker image is nginx:alpine Docker映像为nginx:alpine

What should I change in my configuration? 我应该更改什么配置?

`location @login {
   return 302 https://$http_host/logon?continueURL=https://$http_host;

} ` this line is doing the redirection }`这行正在重定向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM