1日空いてしまった。
uWSGI でデーモンとして動かすことに成功したので、今日は Nginx をリバースプロキシにして lcstorage というホスト名で接続できるようにする。
Nginx の前に、uWSGI の設定をちょっと変更。リクエストを待ち受けるのにポートじゃなくて UNIX ソケットを利用するようにする。
[uwsgi] uid = lcstorage gid = lcstorage #http = :8080 socket = /run/uwsgi/lcstorage.sock venv = /home/lcstorage/lcstorage/env wsgi-file = /home/lcstorage/lcstorage/index.py master = true pidfile = /home/lcstorage/lcstorage/lcstorage.pid daemonize = /home/lcstorage/lcstorage/lcstorage.log
http の設定をコメントアウトして socket を設定している。
でもって、sochekt のディレクトリをつくる。
[lcstorage@bigswifty ~]$ sudo mkdir /run/uwsgi [lcstorage@bigswifty ~]$ sudo chmod 777 /run/uwsgi
つぎに、Nginx のバーチャルホストの設定。
/etc/nginx/conf.d/lcstorage.conf ファイルを作る。
upstream uwsgi-lcstorage {
server unix:/run/uwsgi/lcstorage.sock;
}
server {
# port
listen 80;
# server name
server_name lcstorage;
# document root
#root /home/lcstorage/lcstorage;
# index
#index index.php index.html index.htm;
client_max_body_size 4G;
# log files
access_log /var/log/nginx/lcstorage/access.log main;
error_log /var/log/nginx/lcstorage/error.log warn;
keepalive_timeout 60;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
location / {
#root /home/lcstorage/lcstorage;
include uwsgi_params;
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;
uwsgi_pass unix:/run/uwsgi/lcstorage.sock;
}
}
ログファイル用のディレクトリをつくる。
[lcstorage@bigswifty ~]$ sudo mkdir /var/log/nginx/lcstorage
そして、SELinux を無効化。コレ重要。
最後に、マシンをリブートして終了。
無事にバーチャルホストにアクセスできることを確認した。