Skip to content

Instantly share code, notes, and snippets.

@watermouth
Last active December 9, 2019 08:02
Show Gist options
  • Select an option

  • Save watermouth/7b0c35c212a74fd6bf622a8f57a2aae8 to your computer and use it in GitHub Desktop.

Select an option

Save watermouth/7b0c35c212a74fd6bf622a8f57a2aae8 to your computer and use it in GitHub Desktop.
nginx, uwsgi, flask

memo

ubuntu

使用中のプロセスとポート番号

sudo lsof -i
sudo lsof -i:80

daemon起動・停止

  • uwsgi
#/etc/systemd/system/uwsgi.service # を設定する
sudo systemctl reload-daemon # か何か. startなどしようとするとwarningが出るはず.
sudo systemctl start uwsgi

daemon化していてkillしても自動再起動する設定をする (uwsgi.service). kill直後にsystemctl stop uwsgiすれば起き上がってこない.

  • nginx
#/etc/init.d/nginx が設定ファイル?
sudo systemctl start nginx
sudo systemctl start nginx

エラーログ: 502 Bad Gatewayなど出たらこれを見てみる.

tail -f /var/log/nginx/error.log

portforwarding

# localhost:8081番ポートをhoge_proxyから見えるsomehost:80にマッピング
ssh -L 8081:somehost:80 hoge_proxy

構成例

  • flask <-> uwsgi <-> nginx <-> web browser

  • flaskのappが出来たら, uwsgiの設定ファイルを作ってuwsgiを起動する. 当然nginxの設定ファイルも設定済みでないといけない. nginxも起動しないといけない.

参考サイト

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment