nginx

Not sure if this exists or if anyone is using nginx but I was playing around with it last night and build a SES/Coldbox config file for nginx.

Wanted to share it with everyone in case it could help you guys out!
https://github.com/lunarfly/nginx-conf-coldbox-with-ses

I haven’t added the sql-injection rules that Luis built for apache but hopefully will get to that later this week.


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

Would you be willing to donate these to the core?

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

absolutely - let me know what to do.


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

Jeremy, you can also add the following if you want “pure” SES without tuckey:

if (!-f $request_filename) {

rewrite ^/(.*)$ //index.cfm/$1 break;

break;

}

Tom.

~WRD000.jpg

very cool Tom!

I was able to get the rewrites to work by modifying /WEB-INF/web.xml

and adding the following lines

CFMLServlet /index.cfm/*

without Tuckey…but yet again I don’t know how tuckey works so maybe that is what it does for you and if so, i’m sorry for the confusion.


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

~WRD000.jpg

Tuckey is an URL rewriter – but you don’t need it with nginx.

I meant “pure” SES, like: www.domain.com/handler/event (which is rewritten to www.domain.com/index.cfm/handler/event)

~WRD000.jpg

I’ve used nginx quite a lot – so if you need any pointers feel free to ask :slight_smile:

Here’s some extra config which I use in one of my sites in case you’re interested. It utilises front end caching for cfm pages based on JSESSIONID (so user specific caching), and then non-user specific caching for static files.

define two local caches.

proxy_cache_path /var/lib/nginx/staticcache levels=1:2 keys_zone=staticfilecache:1024m max_size=40g inactive=7d;

proxy_cache_path /var/lib/nginx/websitecache levels=1:2 keys_zone=websitecache:1024m max_size=40g inactive=1d;

server {

listen 80; ## listen for ipv4

server_name mywebsite.com; ## myserver name

index index.cfm; ## index page

gzip_vary on; ## enable gzip

gzip_static on;

location / {

if (!-f $request_filename) {

rewrite ^/(.*)$ /website/index.cfm/$1 break; ## rewrite all requests – for pure SES.

break;

}

proxy_pass http://127.0.0.1:8080/website/; ## pass all to this context root

proxy_cache websitecache; ## specific the cache to use for this location

proxy_cache_valid 200 302 1d; ## specify a cache timeout for the reponse code

proxy_cache_valid 307 404 500 400 1m; ## only cache these temporarily

proxy_cache_key “$scheme$host$request_method$request_uri$cookie_JSESSIONID”; ## the key for caching requests

proxy_cache_bypass $cookie_isAdmin; ## never cache administrators

proxy_no_cache $cookie_isAdmin; ## never cache administrators

access_log /var/log/nginx/cache.log cache; ## log cache requests to a cache log

}

location /includes {

root /usr/share/tomcat6/webapps/website/;

proxy_cache staticfilecache; ## specify the cache to use for this location

proxy_cache_valid 200 302 7d; ## specify a cache timeout for the reponse code

proxy_cache_valid 307 404 500 400 1m; ## only cache these temporarily

proxy_ignore_headers Set-Cookie; ## ignore cookie data for this cache

add_header Cache-Control “public, max-age=315360000”; ## set some headers for client side caching

expires max;

}

}

~WRD000.jpg

Tom, I am able to acomplish the same thing with Apache/Tomcat by using a simple rewrite rule as seen below.

RewriteCond %{REQUEST_URI} /
RewriteRule ^/(.*)$ balancer://ajpCluster/index.cfm/$1 [P]

Are you talking about using Tomcat directly without Apache as the front-end server?


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

~WRD000.jpg

awesome thanks!


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

~WRD000.jpg

Tuckey helps if you want to use tomcat as a front end server without apache – but essentially the rule I gave you is a nginx equivalent of yours below.

~WRD000.jpg

Gotcha. Makes sense!


Jeremy R. DeYoung
Phone:615.261.8201

RantsFromAMadMan.com

~WRD000.jpg