Skip to content

Instantly share code, notes, and snippets.

@JKring
Last active September 28, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JKring/1487210 to your computer and use it in GitHub Desktop.
Save JKring/1487210 to your computer and use it in GitHub Desktop.
Scripted Nginx Configuration
user deploy;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream scripted {
server unix:/home/deploy/cap/current/tmp/sockets/unicorn.sock;
}
server {
client_max_body_size 20M;
listen 80;
server_name scripted.com;
# rewrite ^ https://$server_name$request_uri?;
#charset koi8-r;
location ~* ^.+\.(jpg|pdf|jpeg|gif|png|ico|css|js|swf|haml|ttf)$ {
root /home/deploy/cap/current/public;
expires max;
access_log off;
}
#access_log logs/host.access.log main;
location / {
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://scripted;
error_page 401 402 403 404 500 501 502 503 504 /50x.html;
}
location /50x.html {
root /home/deploy/cap/current/public;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
server_name www.scripted.com;
rewrite ^ https://scripted.com$request_uri? permanent;
}
server {
listen 8887;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8888/;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
server {
listen 443;
client_max_body_size 20M;
ssl on;
ssl_certificate /usr/ssl/server.crt;
ssl_certificate_key /usr/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|pdf|css|js|swf|haml|ttf)$ {
root /home/deploy/cap/current/public;
expires max;
access_log off;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://scripted;
error_page 401 402 403 404 500 501 502 503 504 /50x.html;
}
location ~ ^/assets/ {
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment