Skip to content

Instantly share code, notes, and snippets.

@avokhmin
Last active December 14, 2015 20:09
Show Gist options
  • Save avokhmin/5142123 to your computer and use it in GitHub Desktop.
Save avokhmin/5142123 to your computer and use it in GitHub Desktop.
/etc/nginx/conf.d/rosa_build.conf
upstream rosa_build_backend {
# server 127.0.0.1:8080;
server unix:/tmp/rosa_build_unicorn.sock;
}
server {
listen 80;
server_name 127.0.0.1;
root /srv/rosa_build/current/public;
if ($uri !~ downloads) {
rewrite ^(.*) https://$host$1 permanent;
}
location /downloads {
autoindex on;
}
access_log /srv/rosa_build/shared/log/nginx.access.log;
error_log /srv/rosa_build/shared/log/nginx.error.log;
#rewrite ^/downloads/(.*) http://$host/downloads/$1 break;
}
server {
listen 443 default ssl;
server_name 127.0.0.1;
root /srv/rosa_build/current/public;
ssl on;
ssl_certificate /etc/ssl/abf.crt;
ssl_certificate_key /etc/ssl/abf.key;
#ssl_verify_depth 3;
location ~ ^/(assets)/ {
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri.html $uri @myapp;
location @myapp {
#proxy_set_header Host $host;
proxy_set_header Host $http_host;
# proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300;
proxy_send_timeout 180;
proxy_redirect off;
proxy_pass http://rosa_build_backend;
}
rewrite ^/downloads/(.*) http://$host/downloads/$1 break;
#access_log /srv/rosa_build/shared/log/nginx.access.log;
#error_log /srv/rosa_build/shared/log/nginx.error.log;
error_page 500 502 504 /500.html;
location = /500.html {
root /srv/rosa_build/current/public;
}
# This allows people to use images and css in their maintenance.html file
if ($request_filename ~* \.(css|jpg|gif|png)$) {
break;
}
if (-f $document_root/system/maintenance.html) {
#error_page 503 /srv/rosa_build/current/public/503.html;
return 503;
}
error_page 503 @maintenance;
location @maintenance {
root /srv/rosa_build/current/public;
rewrite ^(.*)$ /503.html break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment