Skip to content

Instantly share code, notes, and snippets.

@brennanneoh
Created April 29, 2011 04:10

Revisions

  1. Brennan Neoh revised this gist Oct 23, 2011. 1 changed file with 17 additions and 15 deletions.
    32 changes: 17 additions & 15 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -32,22 +32,28 @@ http {
    #gzip on;

    server {
    listen 80;
    server_name gov.brennan.sg;
    listen 80;
    server_name music.brennan.sg;

    location / {
    root /srv/http/nginx/gov;
    index index.php;
    try_files $uri $uri/ index.php;
    }
    location ~ / {
    proxy_pass http://localhost:4040;
    }
    }

    location = index.php {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    server {
    listen 80;
    server_name 122.248.237.242;
    root /srv/http/nginx;

    location ~ \.php$ {
    try_files $uri $uri/;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/gov/index.php;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name
    ;
    include fastcgi_params;
    }
    }
    }

    server {
    listen 80;
    @@ -59,23 +65,19 @@ http {
    }

    location /phpmyadmin {
    root /srv/http/nginx;
    index index.php;
    }

    location /thinkup {
    root /srv/http/nginx;
    index index.php;
    }

    location /us {
    root /srv/http/nginx;
    index index.php;
    try_files $uri $uri/ @kohana;
    }

    location /koko {
    root /srv/http/nginx;
    index index.php;
    try_files $uri index.php @koko;
    }
  2. Brennan Neoh revised this gist May 4, 2011. 1 changed file with 34 additions and 5 deletions.
    39 changes: 34 additions & 5 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -32,12 +32,26 @@ http {
    #gzip on;

    server {
    listen 80;
    server_name localhost;
    listen 80;
    server_name gov.brennan.sg;

    #charset koi8-r;
    location / {
    root /srv/http/nginx/gov;
    index index.php;
    try_files $uri $uri/ index.php;
    }

    #access_log logs/host.access.log main;
    location = index.php {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/gov/index.php;
    include fastcgi_params;
    }
    }

    server {
    listen 80;
    server_name tux.brennan.sg;

    location / {
    root /srv/http/nginx;
    @@ -60,6 +74,13 @@ http {
    try_files $uri $uri/ @kohana;
    }

    location /koko {
    root /srv/http/nginx;
    index index.php;
    try_files $uri index.php @koko;
    }


    # HANDLES THE REWRITTEN URLS TO KOHANA CONTROLLER
    location @kohana
    {
    @@ -69,6 +90,14 @@ http {
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/us/index.php;
    }

    location @koko
    {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/koko/index.php;
    }

    location ~ /music {
    proxy_pass http://127.0.0.1:4040;
    }
    @@ -96,7 +125,7 @@ http {
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    try_files $uri $uri/ @kohana;
    try_files $uri $uri/;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;
  3. Brennan Neoh created this gist Apr 29, 2011.
    157 changes: 157 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,157 @@
    #user http;
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    #pid logs/nginx.pid;


    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log logs/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;

    server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root /srv/http/nginx;
    index index.html index.htm;
    }

    location /phpmyadmin {
    root /srv/http/nginx;
    index index.php;
    }

    location /thinkup {
    root /srv/http/nginx;
    index index.php;
    }

    location /us {
    root /srv/http/nginx;
    index index.php;
    try_files $uri $uri/ @kohana;
    }

    # HANDLES THE REWRITTEN URLS TO KOHANA CONTROLLER
    location @kohana
    {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/us/index.php;
    }

    location ~ /music {
    proxy_pass http://127.0.0.1:4040;
    }

    location /webmin/ {
    rewrite ^(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:10000;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    # proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
    try_files $uri $uri/ @kohana;
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;
    include fastcgi_params;
    }

    location = /index.php {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    # deny all;
    #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}


    # HTTPS server
    #
    #server {
    # listen 443;
    # server_name localhost;

    # ssl on;
    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_timeout 5m;

    # ssl_protocols SSLv2 SSLv3 TLSv1;
    # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

    }