Skip to content

Instantly share code, notes, and snippets.

@robertz
Last active December 11, 2015 07:39
Show Gist options
  • Save robertz/4568027 to your computer and use it in GitHub Desktop.
Save robertz/4568027 to your computer and use it in GitHub Desktop.
Sample Nginx configuration
server {
listen 80;
server_name my.site.com;
root /var/www/my.site.com;
location / {
# Rewrite rules and other criterias can go here
# Remember to avoid using if() where possible (http://wiki.nginx.org/IfIsEvil)
try_files $uri $uri/ @rewrites;
}
location @rewrites {
# Can put some of your own rewrite rules in here
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
rewrite ^/images/(.*)? http://images.site.com/$1 permanent;
rewrite ^/(.*)? /index.cfm/$1 last;
rewrite ^ /index.cfm last;
}
# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(?:ico|css|js)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# We can include our basic configs here, as you can see its much easier
# than pasting out the entire sets of location block each time we add a vhost
include drop.conf;
# Main Railo proxy handler
location ~ \.(cfm|cfml|cfc|jsp|cfr)(.*)$ {
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Server $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8888;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment