Unicorn + Nginxで運用中のサービスで一部機能をサブドメインにしたいのですが、サブドメインがドメインにリダイレクトしうまくいきません。
hoge.example.comにアクセスするとexample.comにリダイレクトしてしまいます。
DNSの設定は下記の通りです。
タイプ | 名称 | IPアドレス |
---|---|---|
A | @ | IPアドレス |
A | hoge | IPアドレス |
※サイトは表示されているのでネームサーバーの設定は大丈夫だと思います。
Unicorn、Nginxどちらかの問題だと疑っているのですが、わかる方ご教示頂けますと幸いです。
nginx側の設定は下記の通りです。 upstream unicorn { server unix:/var/www/example/shared/tmp/sockets/unicorn.sock; } server { listen 80; server_name example.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/example/current/public; location @unicorn { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn; } }
nginxのログは下記の通り管理しております。 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
hoge.example.comアクセス時のaccess.log IPアドレス - - [21/Dec/2017:16:18:34 +0900] "GET / HTTP/1.1" 301 96 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36"