發表文章

目前顯示的是有「nginx」標籤的文章

django, gunicorn, nginx下設定subpath

google上找到滿多都是apache和uwsgi的設定, 這個設定讓我花了好一段時間才找到。 設定是wsgi server和有用nginx的upstream才有用 很簡單只需要設定 proxy_set_header SCRIPT_NAME $your_subpath 這樣django就會正常囉! 以下是稍微詳細一點的nginx設定 upstream some_urls {   # fail_timeout=0 means we always retry an upstream even if it failed   # to return a good HTTP response (in case the Unicorn master nukes a   # single worker for timing out).   server unix:/path/to/your/gunicorn/socket fail_timeout=0; } server {     listen   80;     server_name example.com;     client_max_body_size 4G;     location /your_subpath/ {         # an HTTP header important enough to have its own Wikipedia entry:         #   http://en.wikipedia.org/wiki/X-Forwarded-For         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;         # enable this if and only ...