Created
December 30, 2013 19:20
-
-
Save mariocesar/8186668 to your computer and use it in GitHub Desktop.
NGINX Vhost configuration to serve dynamic virtual host using domain names as the website router
This file contains hidden or 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 { | |
index index.html index.php index.htm; | |
server_name ~^(www\.)?(?P<domain>.+)$; | |
root /var/www; | |
location @notfound { | |
root /home/websites/Websites; | |
access_log on; | |
rewrite ^ /404.html last; | |
} | |
location @server_error { | |
try_files 500.html /../500.html =500; | |
} | |
#error_page 404 = @notfound; | |
error_page 500 = @server_error; | |
location = /favicon.ico { | |
access_log off; | |
log_not_found off; | |
} | |
location / { | |
index index.html index.php; | |
access_log /var/log/nginx/access.websites.log; | |
error_log /var/log/nginx/error.websites.log error; | |
root /home/websites/Websites/$domain; | |
try_files $uri $uri/ /index.php; # Soporte para la mayoria de los frameworks PHP, como Laravel, Symfony o CakePHP | |
} | |
# Cualquier archivo que empieze por . o _ debe ser protegido. | |
location ~ /[._]+ { | |
root /home/websites/Websites; | |
#try_files $uri =404; | |
#error_page 404 @notfound; | |
error_page 404 /home/websites/Websites/404.html; | |
} | |
# Cualquier archivo .php debe ser interpretado por php-fpm | |
location ~ .php$ { | |
root /home/websites/Websites/$domain; | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param SERVER_NAME $host; | |
fastcgi_intercept_errors on; | |
fastcgi_ignore_client_abort off; | |
fastcgi_connect_timeout 60; | |
fastcgi_send_timeout 180; | |
fastcgi_read_timeout 180; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 4 256k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment