Last active
December 15, 2015 11:38
-
-
Save gam-phon/5254018 to your computer and use it in GitHub Desktop.
Sample Nginx configuration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahlaaaa