Last active
February 13, 2017 20:12
-
-
Save jyfcrw/d047f98cb0c9b30686c7 to your computer and use it in GitHub Desktop.
Nginx server configuration with X-Sendfile for Rails
This file contains hidden or 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
server { | |
listen 80; | |
listen [::]:80; | |
server_name mydomian.com *.mydomian.com; | |
root /var/www/default/apps/myproject/current/public; | |
passenger_enabled on; | |
passenger_set_header X-Sendfile-Type "X-Accel-Redirect"; | |
passenger_env_var HTTP_X_ACCEL_MAPPING /var/www/default/apps/myproject/shared/public/protects/=/protects/; | |
passenger_pass_header X-Accel-Redirect; | |
access_log /var/log/nginx/myproject.log; | |
error_log /var/log/nginx/myproject.log; | |
location ~ ^/(assets|uploads)/ { | |
gzip on; | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
add_header ETag ""; | |
} | |
location ~ /protects/(.*) { | |
internal; | |
alias /var/www/default/apps/myproject/shared/public/protects/$1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment