Created
July 30, 2015 13:01
-
-
Save silviopaganini/7f20bd85b1c7ab55bebc to your computer and use it in GitHub Desktop.
nginx config
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
server { | |
access_log "/var/log/nginx/server.${domain}.access.log"; | |
error_log "/var/log/nginx/server.dev.error.log"; | |
charset utf-8; | |
listen 80; | |
index index.html index.htm index.php; | |
set $basepath "/var/www/domains/projects"; | |
set $domain $host; | |
set $htdocs "www"; | |
if ($host ~* www\.(.*)) { | |
set $domain $1; | |
} | |
if ($domain ~* fluuu) { | |
set $basepath "/var/www/domains"; | |
set $htdocs ""; | |
} | |
root $basepath/$domain/$htdocs; | |
server_name $domain; | |
# location / { | |
# add_header Access-Control-Allow-Origin '*'; | |
# try_files $uri $uri/ /index.html =404; | |
# # needed to forward user's IP address to backend | |
# proxy_set_header X-Real-IP $remote_addr; | |
# # needed for HTTPS | |
# #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# #proxy_set_header X-Forwarded-For $remote_addr; | |
# #proxy_set_header Host $http_host; | |
# #proxy_max_temp_file_size 0; | |
# #proxy_headers_hash_max_size 512; | |
# set $send_to_app "yes"; | |
# # Handle all images and assets explicitly. Faster than fs check every time. | |
# if ($request_uri ~ "images/|img/|data/|javascripts/|js/|stylesheets/|css/") { | |
# set $send_to_app "no"; | |
# break; | |
# } | |
# include /etc/nginx/include/php; | |
# } | |
location / { | |
# if you're just using wordpress and don't want extra rewrites | |
# then replace the word @rewrites with /index.php | |
try_files $uri $uri/ /www-data/index.html /www/index.html /index.html; | |
} | |
location @rewrites { | |
# Can put some of your own rewrite rules in here | |
# for example rewrite ^/~(.*)/(.*)/? /users/$1/$2 last; | |
# If nothing matches we'll just send it to /index.php | |
rewrite ^ /index.html last; | |
} | |
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { | |
# Some basic cache-control for static files to be sent to the browser | |
gzip on; | |
expires max; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
# remove the robots line if you want to use wordpress' virtual robots.txt | |
location = /robots.txt { access_log off; log_not_found off; } | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location ~ /\.{ access_log off; log_not_found off; deny all; } | |
error_page 403 404 405 500 501 502 503 504 /404.html; | |
location ~^/404.html { | |
root /var/www/domains/fluuu.id; | |
internal; | |
} | |
location ~ \.php$ { | |
# http://forum.nginx.org/read.php?2,88845,page=3 | |
try_files $uri =404; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock; | |
fastcgi_index index.php; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment