Skip to content

Instantly share code, notes, and snippets.

@ahmpro
Created November 8, 2012 12:39
Show Gist options
  • Save ahmpro/4038554 to your computer and use it in GitHub Desktop.
Save ahmpro/4038554 to your computer and use it in GitHub Desktop.
nginx simple config
# nginx simple config
# author: worldwide community
# edit: Vladislav Klimanov (ahmpro@rslayers.com)
# note: replace 'example.com' with your domain
# i like use uncommented this section for nginx/sites-available/default and comment next
#server {
# listen 80 default_server;
# error_log /dev/null crit;
# return 403;
#}
server {
listen 80;
server_name example.com www.example.com;
error_log /var/log/nginx/example.com.error_log;
access_log /var/log/nginx/example.com.access_log;
# hide .git, .svn, .ht* (ex: .htaccess)
location ~ /\.git {
deny all;
}
location ~ /\.svn {
deny all;
}
location ~ /\.ht {
deny all;
}
# merge www.example.com and example.com to example.com
if ($host = 'www.example.com' ) {
rewrite ^/(.*)$ http://example.com/$1 permanent;
}
# static, check path
location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
root /var/www/example.com/www/;
}
# backend on 127.0.0.1:8181
location / {
proxy_pass http://127.0.0.1:8181;
proxy_redirect http://example.com:8181/ /;
proxy_redirect http://www.example.com:8181/ /;
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_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment