Last active
February 28, 2020 11:35
-
-
Save nesquena/485042 to your computer and use it in GitHub Desktop.
nginx configuration
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
include mime.types; | |
default_type application/octet-stream; | |
access_log logs/access.log; | |
sendfile on; | |
keepalive_timeout 65; | |
tcp_nodelay on; | |
tcp_nopush on; |
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
gzip on; | |
gzip_comp_level 2; | |
gzip_proxied any; | |
gzip_buffers 16 8k; | |
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
gzip_disable "MSIE [1-6].(?!.*SV1)"; |
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
worker_processes 4; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
# Passenger Global Configurations | |
include /opt/nginx/conf/includes/passenger.conf; | |
# Basic Nginx Configuration | |
include /opt/nginx/conf/includes/base.conf; | |
# Gzip Compression Configuration | |
include /opt/nginx/conf/includes/gzip.conf; | |
# Miso Application Server (http://gomiso.com) | |
server { | |
listen 8080; | |
server_name gomiso.com seacliff.gomiso.com localhost; | |
root /var/apps/gomiso/current/public; | |
include /opt/nginx/conf/includes/server.conf; | |
} | |
# CodePath (https://codepath.com) | |
server { | |
listen 443; | |
server_name gomiso.com; | |
root /var/apps/gomiso/current/public; | |
include /opt/nginx/conf/includes/server.conf; | |
include /opt/nginx/conf/includes/ssl.conf; | |
} | |
} |
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
# Passenger global settings | |
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2; | |
passenger_ruby /usr/local/bin/ruby; | |
passenger_max_pool_size 10; | |
passenger_min_instances 2; | |
passenger_pool_idle_time 0; | |
passenger_max_instances_per_app 0; | |
passenger_pre_start http://railsapp.com; |
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
# /opt/nginx/conf/includes/server.conf | |
# Passenger server specific settings | |
passenger_enabled on; | |
passenger_use_global_queue on; | |
rails_spawn_method smart-lv2; | |
rack_env production; | |
# Rewrite /media/... to /m/... | |
location /media/ { | |
server_name_in_redirect off; | |
rewrite (/media/)(.*)$ /m/$2 permanent; | |
} | |
# Rewrite /users/... to /u/... | |
location /users/ { | |
server_name_in_redirect off; | |
rewrite (/users/)(.*)$ /u/$2 permanent; | |
} | |
# Rewrites to maintenance page for capistrano if exists. | |
if (-f $document_root/system/maintenance.html){ | |
rewrite ^(.*)$ /system/maintenance.html break; | |
} | |
# If files exist in public root, serve them directly | |
if (-f $document_root/cache/$uri/index.html) { | |
rewrite (.*) /cache/$1/index.html break; | |
} | |
# If the file is stored in the cache folder, serve the file | |
if (-f $document_root/cache/$uri) { | |
rewrite (.*) /cache/$1 break; | |
} | |
# If the file is stored in the cache and has an html extension, serve the file | |
if (-f $document_root/cache/$uri.html) { | |
rewrite (.*) /cache/$1.html break; | |
} | |
# Sets an expires header for any assets with a query string | |
location ~* (stylesheets|javascripts|images|juggernaut) { | |
if (!-f $request_filename) { | |
break; | |
} | |
if ($query_string ~* "^[0-9]{3,}$") { | |
expires max; | |
break; | |
} | |
} | |
# Assets (Jammit) gzipping | |
location ~* "/assets/" { | |
expires max; | |
break; | |
} | |
# Dragonfly asset caching (must go to passenger) | |
location ~* \/uploads\/ { | |
expires max; | |
passenger_enabled on; | |
} | |
# error_page 500 502 503 504 /50x.html; | |
# location = /50x.html { | |
# root html; | |
# } |
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
ssl on; | |
ssl_certificate /opt/nginx/conf/ssl/railsapp.com.crt; | |
ssl_certificate_key /opt/nginx/conf/ssl/railsapp.com.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; | |
# needed for HTTPS | |
proxy_set_header X_FORWARDED_PROTO https; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_max_temp_file_size 0; | |
# needed to forward user's IP address to rails | |
proxy_set_header X-Real-IP $remote_addr; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment