Skip to content

Instantly share code, notes, and snippets.

@gam-phon
Last active December 15, 2015 11:38
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 gam-phon/5254018 to your computer and use it in GitHub Desktop.
Save gam-phon/5254018 to your computer and use it in GitHub Desktop.
Sample Nginx configuration.
upstream app_servers {
server 127.0.0.1:8008;
}
server {
listen 80;
server_name www.yr.sa;
index index.html;
location = /favicon.ico {
access_log off;
log_not_found off;
}
# Static Files
# Use this or skip it to the another one.
location ~ /(static|media|js|css|img)/ {
# Prevent hotlinking
valid_referers none blocked yr.sa *.yr.sa;
if ($invalid_referer) {
return 403;
}
root /home/yaser/site_name/www;
expires 365d;
}
location /admin/ {
allow put_your_public_ip;
deny all;
proxy_pass http://app_servers;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://app_servers;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Using uwsgi
#location / {
# include uwsgi_params;
# uwsgi_pass unix:/project_path/project_name.sock;
#}
}
# Example of Redirect yr.sa to www.yr.sa
server {
listen 80;
server_name yr.sa;
rewrite ^ http://www.yr.sa$request_uri? permanent;
}
@moshohayeb
Copy link

ahlaaaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment