初学者配置nginx遇到的端口变化问题
来源:互联网 发布:java的历史 编辑:程序博客网 时间:2024/05/21 17:24
初学者配置nginx遇到的端口变化问题
server { listen 81; server_name localhost; #...此处省略一些配置 location /XXX { proxy_pass http://192.168.1.100:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_redirect off; #sub_filter_once off; #proxy_set_header X-Forwarded-For $http_x_forwarded_for; }}
以上是nginx默认监听端口号为81的情况,并整合了另外一个8080端口的内网WEB。
然后问题出现了,当访问http://localhost:81/XXX 后,浏览器自动跳转到了 http://localhost/XXX,导致访问失败。
原来,如果nginx的监听端口不是默认的80端口,改为其他非80端口后,后端服务tomcat中的request.getServerPort()方法无法获得正确的端口号,仍然返回到80端口。在response.sendRedirect()时,客户端可能无法获得正确的重定向URL。
所以正确的配置:
server { listen 81; server_name localhost; #...此处省略一些配置 location /XXX { proxy_pass http://192.168.1.100:8080; proxy_set_header Host $host:81; #问题就在这里,要增加81端口 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_redirect off; #sub_filter_once off; #proxy_set_header X-Forwarded-For $http_x_forwarded_for; }}
0 0
- 初学者配置nginx遇到的端口变化问题
- nginx 配置遇到的问题
- 配置nginx遇到的问题
- CentOS7 配置nginx 遇到的一些问题
- nginx转发配置shipyard遇到的问题
- 配置php/nginx环境遇到的问题
- 配置nginx+php+mysql遇到的问题
- tomcat与nginx配置遇到的问题
- nginx配置遇到的问题与解决方法(nginx.conf正则)
- MAVEN初学者遇到的问题
- Nginx rtmp 模块安装及配置及遇到的问题
- Linux配置防火墙,开启80端口、3306端口 可能会遇到的小问题
- tomcat与nginx相结合,nginx基于端口配置多个tomcat的问题?
- RecyclerView数据源变化时遇到的问题
- 困扰nginx初学者的两个小问题
- Hadoop初学者常遇到的问题汇总
- 初学者指针会遇到的问题。。
- MySQL 初学者可能会遇到的问题
- 机器学习之一 模型评估及部分概念
- 全球地震及地质灾害实时CSV/JSON/KML数据【免费下载】
- 有用的JS(二)
- 判断输入三边能否构成三角形
- 【bzoj2440】[中山市选2011]完全平方数
- 初学者配置nginx遇到的端口变化问题
- android技术篇(三)解密data区
- 复习JAVA面相对象(类和对象)
- 15 sql语言基础与qt里sqlite, mysql数据库的连接
- 第三方登陆--狸菇凉_
- 页面侧滑2
- printf 打印 指定长度 字符串
- jquery animate step 实现 transform css3方法
- SpringBoot 相关的注意点