Last active
November 8, 2019 18:02
-
-
Save bilaschandra/a2c5dd80541c7970532910eb427d17fe to your computer and use it in GitHub Desktop.
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 { | |
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; } | |
} | |
//======================================================= | |
server { | |
listen 80; | |
root /vagrant; | |
index index.html index.htm index.php app.php app_dev.php; | |
# Make site accessible from http://set-ip-address.xip.io | |
server_name 192.168.33.10.xip.io; | |
access_log /var/log/nginx/vagrant.com-access.log; | |
error_log /var/log/nginx/vagrant.com-error.log error; | |
charset utf-8; | |
# handle static files within project.. break at end to avoid recursive redirect | |
location ~project(\d*)/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ { | |
rewrite project(\d*)/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ /project$1/public/$2 break; | |
} | |
#project1 and project2 are two laravel projects that you want to serve | |
# at http://192.168.33.10.xip.io/project1/ and http://192.168.33.10.xip.io/project2/ respectively | |
location /project1{ | |
rewrite ^/project1/(.*)$ /project1/public/index.php?$1 last; | |
} | |
location /project2 { | |
rewrite ^/project2/(.*)$ /project2/public/index.php?$1 last; | |
} | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
error_page 404 /index.php; | |
# pass the PHP scripts to php5-fpm | |
# Note: \.php$ is susceptible to file upload attacks | |
# Consider using: "location ~ ^/(index|app|app_dev|config)\.php(/|$) {" | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
# With php5-fpm: | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
############# IMPORTANT - This section adjusts the request URI sent to laravel ################# | |
set $laravel_uri $request_uri; | |
if ($laravel_uri ~ project(\d*)(/?.*)$) { | |
set $laravel_uri $2; | |
} | |
###################### Note request uri mod below ############################################## | |
fastcgi_param REQUEST_URI $laravel_uri; | |
fastcgi_param LARA_ENV local; # Environment variable for Laravel | |
fastcgi_param HTTPS off; | |
} | |
# Deny .htaccess file access | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment