内网ip
apache,nginx反向代理出现内网ip解决方法
星期四, 二月 23rd, 2012 | JAVA-and-J2EE, linux | 没有评论
apache中设置如下反向代理后端的tomcat出现
request.getServerName();获取到的主机名称就会是localhost,解决这个
<VirtualHost *:80> ServerAdmin service@i5a6.com DocumentRoot /usr/local/apache/htdocs ServerName i5a6.com ServerAlias *.i5a6.com DirectoryIndex index.html index.html.var index.jsp ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ ErrorLog "logs/hscode-error.log" CustomLog "logs/hscode-access.log" common </VirtualHost> |
在httpd.conf 文件中增加:
ProxyPreserveHost On 即可
对应的nginx 也有此问题解决之法:
proxy_set_header Host $host;
upstream mytomcat{ #server 127.0.0.1:8000 weight=3; #server 127.0.0.1:8001; #server 127.0.0.1:8002; server 127.0.0.1:8080; } server { listen 80; server_name i5a6.com *.i5a6.com; index index.html index.htm ; root /usr/local/data/htdocs/www; location / { # proxy_set_header Host %host; # proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://mytomcat; proxy_set_header Host $host; } |
Search
相关文章
热门文章
最新文章
文章分类
- ajax (10)
- algorithm-learn (3)
- Android (6)
- as (3)
- computer (85)
- Database (30)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (5)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (186)
- linux (143)
- mac (10)
- movie-music (11)
- pagemaker (36)
- php (50)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (6)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (2)
- 低代码 (1)
- 体味生活 (40)
- 前端 (21)
- 大数据 (8)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)