nginx反向代理的问题

youfeng445 2015-01-27 11:31:03

# server configure

server_tokens off;
include mime.types;
default_type application/octet-stream;
#proxy_cache_path /usr/local/nginx/cache levels=1:2:2 keys_zone=cache_one:10m inactive=30m max_size=500m;
#proxy_cache_valid 200 302 10m;
#proxy_cache_valid 404 1m;
proxy_temp_path /usr/local/nginx/proxy_temp_dir;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$request_time"';

access_log logs/access.log main;

sendfile on;
tcp_nopush on;

keepalive_timeout 10;
client_header_timeout 10;
client_body_timeout 10;
reset_timedout_connection on;
send_timeout 10;

gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_min_length 1000;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

open_file_cache max=100000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

#upstream testWeb{
# server 192.168.100.197:9080 max_fails=3 fail_timeout=30s;
#}

proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

server {
listen 80;
server_name localhost;

location / {
#rewrite (.*) http://192.168.100.196/demo1;
proxy_pass http://192.168.100.197:9080/demo1;
}

location /demo1 {
proxy_pass http://192.168.100.197:9080/demo1;
}

}



nginx部署在192.168.100.196上;
demo1访问路径:192.168.100.197:9080/demo1(直接用浏览器可以正常访问)

现在问题是无论访问 192.168.100.196 还是 192.168.100.196/demo1,
浏览器都会跳转为192.168.100.196:9080/demo1.
而且这个配置之前有过几次是可以正常访问,之后添加了其他跳转后,又是时好时坏.
请各位大神指点
...全文
178 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
youfeng445 2015-01-27
  • 打赏
  • 举报
回复
1.6.4和1.7.9都这样,所以我觉得应该是配置的有问题
James-CDD 2015-01-27
  • 打赏
  • 举报
回复
你使用的nginx是哪个版本的?我的1.7.9也遇到这个问题.

19,620

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧