Skip to content

Instantly share code, notes, and snippets.

@mauroartizzu
Created October 2, 2013 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauroartizzu/6794050 to your computer and use it in GitHub Desktop.
Save mauroartizzu/6794050 to your computer and use it in GitHub Desktop.
NGINX Config PHP - Rails
upstream rails {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
server_name ~^(?<domain>[^\.]+)\.(?<tld>[^\.]+)$;
root /var/www/vhosts/$domain.$tld/htdocs;
location / {
index index.html index.htm index.php;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/$domain.$tld/htdocs$fastcgi_script_name;
}
location @ruby {
proxy_pass http://myapp;
}
}
# config sottodominio
server {
listen 80;
server_name ~^(?<sub>[^\.]*)\.?(?<domain>[^\.]+)\.(?<tld>[^\.]+)$;
root /var/www/vhosts/$domain.$tld/subs/$sub/htdocs;
location / {
index index.html index.htm index.php;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/$domain.$tld/subs/$sub/htdocs$fastcgi_script_name;
}
location @ruby {
proxy_pass http://rails;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment