Skip to content

Instantly share code, notes, and snippets.

@WyriHaximus
Created March 25, 2013 17:05
Show Gist options
  • Save WyriHaximus/5238720 to your computer and use it in GitHub Desktop.
Save WyriHaximus/5238720 to your computer and use it in GitHub Desktop.
upstream websocketdomain{
server 127.0.0.1:54321;
}
server {
server_name domain;
access_log /path/to/logs/domain.access_log;
error_log /path/to/logs/domain.error_log;
index index.php index.html;
root /path/to/domain/app/webroot;
location = /websocket {
proxy_pass http://websocketdomain;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
location ~ .*\.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /path/to/domain$fastcgi_script_name;
}
set $cache_extension '';
if ($request_method = GET) {
set $cache_extension '/index.html';
}
if (-f $document_root/cache_html/$request_uri$cache_extension) {
rewrite ^(.*)$ /cache_html/$request_uri$cache_extension;
break;
}
if ($request_uri = '/websocket') {
set $test W;
}
if (!-e $request_filename) {
set $test "${test}P";
}
if ($test = P) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment