2017-10-18 8 views
1
nginx version: nginx/1.10.2 
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013 
TLS SNI support enabled 
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-ipv6 --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' 

以下は一般的な設定です(nginx.conf、私はいくつかの行を切り捨てました)。なぜnginxは私のリクエストをwwwにリダイレクトしますか? <upstream> .com?

user nginx; 

http { 
    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    charset utf-8; 

    server_names_hash_bucket_size 128; 
    client_header_buffer_size 16k; 
    large_client_header_buffers 4 32k; 
    client_max_body_size 50m; 

    open_file_cache max=204800 inactive=20s; 
    open_file_cache_min_uses 1; 
    open_file_cache_valid 30s; 

    sendfile on; 
    tcp_nopush  on; 

    keepalive_timeout 65; 
    tcp_nodelay on; 

    gzip on; 
    gzip_comp_level 6; 
    gzip_vary on; 
    gzip_min_length 1000; 
    gzip_proxied any; 
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript; 
    gzip_buffers 16 8k; 

    include /etc/nginx/conf.d/*.conf; 
    server_tokens off; 
} 

以下はサブconfです。

upstream wls_abc_pool { 
    ip_hash; 
    server wls_abc_1:8006 weight=1 max_fails=3 fail_timeout=10s; 
    server wls_abc_2:8006 weight=1 max_fails=3 fail_timeout=10s; 
} 
server { 
    listen  80; 
    server_name abc.foo.com; 

    location /wls_abc { 
     proxy_pass http://wls_abc_pool; 
     proxy_set_header X-Real-IP  $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Accept-Encoding ""; 
    } 
} 

私はhttp://hostname/wls_abc/またはhttp://abc.foo.com/wls_abc/にアクセスしようとすると、ブラウザは私が正しくたいページをretrun。 http://hostname/wls_abcまたはhttp://abc.foo.com/wls_abcにアクセスしようとすると、ブラウザはhttp://www.wls_abc_pool.com/wls_abc/にリダイレクトされます。それは変です。


  • http://abc.foo.com/wls_abc - >奇妙なリダイレクト
  • http://abc.foo.com/wls_abc/ - >通常
  • http://hostname/wls_abc - >奇妙なリダイレクト
  • http://hostname/wls_abc/ - >

答えて

0

通常、あなたはそれがと一致する場合または末尾にスラッシュを入れずに、あなたの位置規則をregex、somethiに変更する必要があります以下のようなNG:?

場所〜^/wls_abc/$ {

簡単な説明:

-^- start of input 
- /wls_abc - what to match 
- /? - one or zero/characters 
- $ - end of input. 
関連する問題