この記事について
この記事はインフラ初心者がWebページをVPS上で公開したい!って思ってやったことを備忘録として書き残したものです。素人が書いているため情報の信憑性は保証しません。詳細は各自で調べながらやることをおすすめします。記事のとおりにやっておかしなことになっても責任は取れませんのでご了承ください。
事前準備
この記事の内容が済んでいることが前提です。
サーバーはunicorn、nginxを使用しています。
https://qiita.com/piny940/items/e938736d3ce9a56e5b5a
変更点
nginxの設定を下記のように変えます。ポート番号は一意にします。
server {
listen 80;
server_name app1.example.com;
root /var/www/app1/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8001;
}
try_files $uri/index.html $uri @unicorn;
error_page 500 502 503 504 /500.html;
}
unicorn.rbのポート番号の部分を変更
# ポート番号を指定
listen 8001
参考資料
Nginx, Unicornで作るRailsアプリ
https://umatomakun.hatenablog.com/entry/2014/04/25/005445
setting up a virtual host with unicorn, nginx and capistrano in rails
https://stackoverflow.com/questions/13469812/setting-up-a-virtual-host-with-unicorn-nginx-and-capistrano-in-rails