[英]how to prevent Nginx to redirect location to a configured proxy_pass url and port number
Hi guys i am having a problem with nginx, i have configure phpmyadmin
to run with nginx phpmyadmin
is configured to run on port 8080 . 嗨,大家好,我对nginx有问题,我已经将phpmyadmin
配置为与nginx一起运行phpmyadmin
被配置为在端口8080上运行。 I access phpmyadmin
via localhost/phpmyadmin and it give me the proper login screen below. 我通过localhost / phpmyadmin访问phpmyadmin
,它为我在下面提供了正确的登录屏幕。
phpmyadmin login screen phpmyadmin登录屏幕
after login the url on the address bar changes to the configure port from localhost/phpmyadmin to localhost:8080/phpmyadmin and it throws 登录后,地址栏上的URL更改为配置端口,从localhost / phpmyadmin更改为localhost:8080 / phpmyadmin并抛出
here is my nginx configuration: 这是我的nginx配置:
server{
listen 443 ssl;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_certificate /etc/certificate/live/localhost/permission.pem;
ssl_certificate_key /etc/certificate/live/localhost/privkey.pem;
include /etc/certificate/live/localhost/ssl-nginx.conf;
access_log /var/log/nginx/apache2-access.log;
error_log /var/log/nginx/apache2-error.log;
location /phpmyadmin{
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $http_host;
proxy_set_header X-Ssl on;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/phpmyadmin;
proxy_redirect off;
}
} }
Thanks in advance. 提前致谢。
You should not be using proxy_redirect off;
您不应该使用proxy_redirect off;
. 。 You want to change the redirects 您想更改重定向
location /phpmyadmin{
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $http_host;
proxy_set_header X-Ssl on;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/phpmyadmin;
proxy_redirect http://127.0.0.1:8080/ $scheme://$host/;
proxy_redirect http://localhost:8080/ $scheme://$host/;
proxy_cookie_domain 127.0.0.1 $host;
proxy_cookie_domain localhost $host;
}
And you also want to setup the cookie so login works 而且您还想设置Cookie,以便登录有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.