-
-
Save Ismaaa/1fad085e361176843e2572d827333eae to your computer and use it in GitHub Desktop.
Nginx Multi-Site for Laravel
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 { | |
listen 80; | |
server_name demo.example.com; | |
return 301 https://demo.example.com$request_uri; | |
} | |
server { | |
listen 443 ssl spdy; | |
server_name demo.example.com; | |
ssl on; | |
ssl_certificate /etc/nginx/demo.example.com.chained.crt; | |
ssl_certificate_key /etc/nginx/demo.example.com.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM; | |
ssl_prefer_server_ciphers on; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
charset utf-8; | |
autoindex off; | |
autoindex_exact_size off; | |
location / { | |
root /var/www/html/demo; | |
index index.php; | |
try_files $uri $uri/ =404; | |
} | |
location /site1 { | |
access_log /var/log/nginx/site1_access.log; | |
error_log /var/log/nginx/site1_error.log error; | |
location = /site1/ { | |
rewrite ^(.*)$ /site1/index.php last; | |
} | |
alias /var/www/html/demo/site1/public; | |
index index.php; | |
if (-f $request_filename) { | |
break; | |
} | |
rewrite ^(.*)$ /site1/index.php last; | |
} | |
location ~ /site1/.+\.php$ { | |
root /var/www/html/demo/site1/public; | |
include fastcgi_params; | |
fastcgi_intercept_errors off; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param SCRIPT_FILENAME /var/www/html/demo/site1/public/index.php; | |
fastcgi_param HTTPS on; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
} | |
location /site2 { | |
access_log /var/log/nginx/site2_access.log; | |
error_log /var/log/nginx/site2_error.log error; | |
location = /site2/ { | |
rewrite ^(.*)$ /site2/index.php last; | |
} | |
alias /var/www/html/demo/site2/public; | |
index index.php; | |
if (-f $request_filename) { | |
break; | |
} | |
rewrite ^(.*)$ /site2/index.php last; | |
} | |
location ~ /site2/.+\.php$ { | |
root /var/www/html/demo/site2/public; | |
include fastcgi_params; | |
fastcgi_intercept_errors off; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param SCRIPT_FILENAME /var/www/html/demo/site2/public/index.php; | |
fastcgi_param HTTPS on; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
} | |
location /site3 { | |
access_log /var/log/nginx/site3_access.log; | |
error_log /var/log/nginx/site3_error.log error; | |
location = /site3/ { | |
rewrite ^(.*)$ /site3/index.php last; | |
} | |
alias /var/www/html/demo/site3/public; | |
index index.php; | |
if (-f $request_filename) { | |
break; | |
} | |
rewrite ^(.*)$ /site3/index.php last; | |
} | |
location ~ /site3/.+\.php$ { | |
root /var/www/html/demo/site3/public; | |
include fastcgi_params; | |
fastcgi_intercept_errors off; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param SCRIPT_FILENAME /var/www/html/demo/site3/public/index.php; | |
fastcgi_param HTTPS on; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
} | |
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; } | |
location ~ ~$ { access_log off; log_not_found off; deny all; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment