SSLアクセラレータ下でnginx使うときのservername

server { 
  listen 8443;
  ## その他の設定
}

こうしていると、リダイレクトがかかったときに locationヘッダにもportが含まれちゃうなー。

$ curl -I  https://nginx.example.com/foo
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 07 May 2010 08:44:37 GMT
Content-Type: text/html
Content-Length: 178
Location: http://nginx.example.com:8443/foo/
Connection: keep-alive

となる。apacheのときは

<VirtualHost *:8443>
  ServerName https://nginx.exmaple.com/
  ## その他の設定
</VirtualHost>

とservernameにhttpsと指定すれば、locationヘッダもhttpsで返ってきて解決できたけど。

追記

port_in_redirectをoffにすれば、portは8443じゃなくなった。

が、Locationがhttpsじゃなくてhttpになるな。まいいか。

$ curl -I  https://nginx.example.com/foo
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 07 May 2010 08:44:37 GMT
Content-Type: text/html
Content-Length: 178
Location: http://nginx.example.com/foo/
Connection: keep-alive