我没有任何build议https://www.foobar.com
应该redirect到https://www.foobar.com
规则。 但为什么这样做呢?
这是我的curl
输出:
curl -Ik https://www.foobar.com HTTP/1.1 301 Moved Permanently Content-Length: 184 Content-Type: text/html Date: Wed, 11 Feb 2015 07:22:11 GMT Location: https://www.foobar.com/ Server: nginx/1.4.7 Connection: keep-alive
Nginxconfiguration:
upstream unicorn_www.foobar.com { server unix:/srv/www/foobar/shared/sockets/unicorn.sock fail_timeout=0; } server { listen 80; server_name foobar.com; return 301 https://www.foobar.com$request_uri; } server { listen 80; server_name www.foobar.com; return 301 https://www.foobar.com$request_uri; } server { listen 80; server_name beta.foobar.com; return 301 https://www.foobar.com$request_uri; } server { listen 443; server_name foobar.com; return 301 https://www.foobar.com$request_uri; ssl on; ssl_certificate /etc/nginx/ssl/www.foobar.com.crt; ssl_certificate_key /etc/nginx/ssl/www.foobar.com.key; } server { listen 443; server_name beta.foobar.com; return 301 https://www.foobar.com$request_uri; ssl on; ssl_certificate /etc/nginx/ssl/www.foobar.com.crt; ssl_certificate_key /etc/nginx/ssl/www.foobar.com.key; } server { listen 443; server_name www.foobar.com foobar_staging pantherinae; access_log /var/log/nginx/www.foobar.com-ssl.access.log; ssl on; ssl_certificate /etc/nginx/ssl/www.foobar.com.crt; ssl_certificate_key /etc/nginx/ssl/www.foobar.com.key; keepalive_timeout 5; root /srv/www/foobar/current/public/; location / { try_files $uri/index.html $uri/index.htm @unicorn; } location @unicorn { proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 60; proxy_send_timeout 60; # If you don't find the filename in the static files # Then request it from the unicorn server if (!-f $request_filename) { proxy_pass http://unicorn_www.foobar.com; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /srv/www/foobar/current/public/; } }
这是一个redirect来添加一个尾部的斜线:从www.example.com
到www.example.com/
。
从手册
如果某个位置由以斜杠字符结尾的前缀string定义,并且请求由proxy_pass,fastcgi_pass,uwsgi_pass,scgi_pass或memcached_pass之一处理,则将执行特殊处理。 为了响应URI等于这个string的请求,但没有结尾的斜杠,带有代码301的永久redirect将被返回到所请求的URI,并附有斜线 。
我认为,独angular兽的proxy_pass是触发这一点的原因。
你的configuration中有一个location /
行。 您使用curl -Ik https://www.foobar.com
(请注意您的请求中缺less的斜线/ )执行请求。 缺less斜杠会导致redirect到与“location”指令https://www.example.com/
相匹配的“正确”URL。