Skip to content

Instantly share code, notes, and snippets.

@tonyjunkes
Last active February 3, 2017 19:33
Show Gist options
  • Save tonyjunkes/36efc5b99acfe874f4d2 to your computer and use it in GitHub Desktop.
Save tonyjunkes/36efc5b99acfe874f4d2 to your computer and use it in GitHub Desktop.
Server portion for setting up a proxy to Lucee with rewrite to have index.cfm omitted for SES.
http {
...
server {
listen 80;
server_name mysite.local www.mysite.local;
root C:\websites\mysite\www;
index index.cfm;
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;
}
# 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|gif|jpe?g|png)$ {
# 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";
}
location @rewrites {
# Can put some of your own rewrite rules in here
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last;
rewrite ^/(.*)? /index.cfm/$1 last;
}
# Main Lucee proxy handler
location ~ \.(cfm|cfml|cfc|jsp|cfr)(.*)$ {
proxy_pass http://mysite.local:8080;
proxy_read_timeout 100s;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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