我试图清理我的反向代理nginxconfiguration我的url。 我的configuration看起来像这样
upstream blog { ip:port; } server { listen 80; server_name domain.tdl www.domain.tdl; rewrite ^/index.html$ / redirect; rewrite ^(/.+)/index.html$ $1 redirect; if ($request_uri ~* ".html") { rewrite (?i)^(.*)/(.*)\.html $1/$2 redirect; } location / { rewrite ^/(.*) /$1 break; proxy_pass http://blog; } }
只要我博客上的端口是80,一切正常。 但是,如果我改变了其他的东西,nginx会尝试将我的请求redirect到domain.tdl:port,这显然不起作用。 我厌倦了proxy_set_header和proxy_redirect的许多组合,但没有为我工作。
根据要求更多的细节,所有的输出都来自curl -Lv :
我将ip:port设置为ip:8000
< HTTP/1.1 301 Moved Permanently < Location: http://blog:8000/archiv/
我将proxy_pass设置为http://blog http://domain.tdl
< HTTP/1.1 301 Moved Permanently < Location: http://domain.tdl/:8000/archiv/
我设置了IP:80
< HTTP/1.1 301 Moved Permanently < Location: http://domain.tdl/archiv/
有没有人知道为什么发生这种情况,或者我可以解决这个问题?