Created
May 9, 2017 10:10
-
-
Save axelerator/01ab50c21a25a1b93164f86a087dfda0 to your computer and use it in GitHub Desktop.
NGINX+UNICORN config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream app { | |
# Path to Unicorn SOCK file, as defined previously | |
server unix:/var/www/APP_NAME/shared/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
server_name APP_NAME.42ls.de APP_NAME.42ls.de; | |
return 301 https://APP_NAME.42ls.de; | |
} | |
server { | |
listen 443 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server; | |
include snippets/ssl.APP_NAME.42ls.de.conf; | |
include snippets/ssl-params.conf; | |
server_name localhost; | |
root /var/www/APP_NAME/current/public; | |
try_files $uri/index.html $uri @app; | |
location @app { | |
proxy_pass http://app; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_redirect off; | |
auth_basic "Restricted"; | |
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
# MAILCATCHER BELOW | |
# As suggested in http://nginx.org/en/docs/http/websocket.html | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
"" close; | |
} | |
server { | |
listen 1081; | |
location / { | |
proxy_pass http://127.0.0.1:1080; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
auth_basic "Restricted"; | |
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment