Skip to content

Instantly share code, notes, and snippets.

@necenzurat
Created December 8, 2012 14:24
Show Gist options
  • Save necenzurat/4240437 to your computer and use it in GitHub Desktop.
Save necenzurat/4240437 to your computer and use it in GitHub Desktop.
nginx configuration file
server {
listen 80; ## listen for ipv4
server_name www.sent.ro sent.ro;
if ($host = 'www.sent.ro' ) {
rewrite ^/(.*)$ http://sent.ro/$1 permanent;
}
access_log /srv/www/sent.ro/logs/access.log;
error_log /srv/www/sent.ro/logs/error.log;
root /srv/www/sent.ro/public_html;
server_tokens off;
add_header Love necenzurat;
## Disable .htaccess and other hidden files
location /. {
return 404;
}
default_type text/html;
index index.php;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/sent.ro/public_html$fastcgi_script_name;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /developer.html {
rewrite ^(.*)$ /developer.php last;
}
location = /multishrink.html {
rewrite ^(.*)$ /multishrink.php last;
}
location = /bookmarlet/load.js {
rewrite ^(.*)$ /bookmarlet/load.php last;
}
location = /stats.html {
rewrite ^(.*)$ /public-stats.php last;
}
location /feed {
rewrite ^/feed.rss /feed.php last;
}
location / {
rewrite ^/([^/]+)\.qrcode$ /qrcode.php?id=$1 last;
rewrite ^/([^/]+)/stats$ /stats.php?id=$1 last;
rewrite ^/([^/]+)+$ /stats.php?id=$1 last;
rewrite ^/([^/]+)/unlock$ /unlock.php?id=$1 last;
if (!-e $request_filename){
rewrite "^/([0-9a-zA-Z-]{1,60})$" /go.php?id=$1 last;
}
}
location = /api.php {
rewrite ^(.*)$ /API/simple.php last;
}
location /API {
rewrite ^/API/write/(get|post)$ /API/write.php?method=$1 last;
rewrite ^/API/read/(get|post)$ /API/read.php?method=$1 last;
}
}
server {
listen 443 ssl; ## listen for ipv4
listen [::]:443 ssl ipv6only=on; ## listen for ipv6
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;
server_name www.sent.ro sent.ro;
if ($host = 'www.sent.ro' ) {
rewrite ^/(.*)$ http://sent.ro/$1 permanent;
}
access_log /srv/www/sent.ro/logs/access.log;
error_log /srv/www/sent.ro/logs/error.log;
root /srv/www/sent.ro/public_html;
server_tokens off;
add_header Love necenzurat;
## Disable .htaccess and other hidden files
location /. {
return 404;
}
default_type text/html;
index index.php;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/sent.ro/public_html$fastcgi_script_name;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = /developer.html {
rewrite ^(.*)$ /developer.php last;
}
location = /multishrink.html {
rewrite ^(.*)$ /multishrink.php last;
}
location = /bookmarlet/load.js {
rewrite ^(.*)$ /bookmarlet/load.php last;
}
location = /stats.html {
rewrite ^(.*)$ /public-stats.php last;
}
location /feed {
rewrite ^/feed.rss /feed.php last;
}
location / {
rewrite ^/([^/]+)\.qrcode$ /qrcode.php?id=$1 last;
rewrite ^/([^/]+)/stats$ /stats.php?id=$1 last;
rewrite ^/([^/]+)+$ /stats.php?id=$1 last;
rewrite ^/([^/]+)/unlock$ /unlock.php?id=$1 last;
if (!-e $request_filename){
rewrite "^/([0-9a-zA-Z-]{1,60})$" /go.php?id=$1 last;
}
}
location = /api.php {
rewrite ^(.*)$ /API/simple.php last;
}
location /API {
rewrite ^/API/write/(get|post)$ /API/write.php?method=$1 last;
rewrite ^/API/read/(get|post)$ /API/read.php?method=$1 last;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment