Skip to content

Instantly share code, notes, and snippets.

@bendo01
Created August 31, 2013 18:26
Show Gist options
  • Save bendo01/6399835 to your computer and use it in GitHub Desktop.
Save bendo01/6399835 to your computer and use it in GitHub Desktop.
nginx with phalcon php, cakephp, laravel
#user nobody;
worker_processes 4;
worker_rlimit_nofile 8192;
worker_priority 0;
events {
multi_accept off;
worker_connections 1024;
use kqueue;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log /opt/local/var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 3600;
#gzip on;
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name localhost;
root /opt/local/www/;
access_log /opt/local/var/log/nginx/access.log;
error_log /opt/local/var/log/nginx/error.log;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
# server_name_in_redirect off;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /opt/local/www/html;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080/;
}
location /phpmyadmin {
root /opt/local/www/;
}
location /phppgadmin {
root /opt/local/www/;
}
location /myx {
root /opt/local/www/;
}
# laravel setting
location /mylaravel {
index index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# phalcon setting
location /xpdpt {
include mime.types;
root /opt/local/www//xpdpt/public;
index index.php index.html index.htm;
#rewrite ^/xpdpt(.*)$ /xpdpt/public/index.php?_url=/$1;
rewrite ^/xpdpt/(.*)$ /xpdpt/public/$1 break;
#try_files $uri $uri/ /index.php;
try_files $uri $uri/ /xpdpt/public/index.php?q=$uri&$args;
}
#location ~ \.css {
#add_header Content-Type text/css;
#}
#location ~ \.js {
#add_header Content-Type application/x-javascript;
#}
location ~* \.(eot|ttf|woff|svg)$ {
add_header Access-Control-Allow-Origin *;
}
location ~ /xpdpt/(.*)\.css {
add_header Content-Type text/css;
}
location ~ /xpdpt/(.*)\.js {
add_header Content-Type application/x-javascript;
}
# cakephp setting
location /mycake {
rewrite ^/mycake/(.*)$ /mycake/app/webroot/$1 break;
try_files $uri $uri/ /mycake/app/webroot/index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
}
# Deny Any Access to .htaccess Files That May Be Present (not usually in issue in Laravel)
# include /etc/nginx/includes/deny_htaccess;
location ~ /\.ht {
deny all;
}
}
server {
listen 81; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name localhost;
root /opt/local/www;
access_log /opt/local/var/log/nginx/access.log;
error_log /opt/local/var/log/nginx/error.log;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
# server_name_in_redirect off;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /opt/local/www/html;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:81;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment