Created
November 6, 2013 00:48
-
-
Save kikumoto/7329037 to your computer and use it in GitHub Desktop.
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 myapp { | |
server unix:///home/rails/myapp/tmp/sockets/puma.socket; | |
} | |
server { | |
listen 80 default_server; | |
server_name myapp; # change to match your URL | |
server_tokens off; | |
root /home/rails/myapp/public; # I assume your app is located at this location | |
access_log /var/log/nginx/myapp_access.log; | |
error_log /var/log/nginx/myapp_error.log; | |
location ~* ^/assets/ { | |
gzip_static on; | |
# Per RFC2616 - 1 year maximum expiry | |
expires 1y; | |
add_header Cache-Control public; | |
# Some browsers still send conditional-GET requests if there's a | |
# Last-Modified header or an ETag header even if they haven't | |
# reached the expiry date sent in the Expires header. | |
add_header Last-Modified ""; | |
add_header ETag ""; | |
break; | |
} | |
location / { | |
gzip_static on; | |
# serve static files from defined root folder;. | |
# @gitlab is a named location for the upstream fallback, see below | |
try_files $uri $uri/index.html $uri.html @myapp; | |
} | |
# if a file, which is not found in the root folder is requested, | |
# then the proxy pass the request to the upsteam | |
location @myapp { | |
proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 | |
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 | |
proxy_redirect off; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://myapp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment