Skip to content

Instantly share code, notes, and snippets.

@reegodev
Created April 14, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reegodev/030f138320687d18fd1d24e82e9b0443 to your computer and use it in GitHub Desktop.
Save reegodev/030f138320687d18fd1d24e82e9b0443 to your computer and use it in GitHub Desktop.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
client_max_body_size 128M;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl_certificate /usr/local/etc/ssl/certs/localhost.crt;
ssl_certificate_key /usr/local/etc/ssl/private/localhost.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 80;
listen [::]:80;
server_name ~^(?<subfolder>.+)\.wp.local$;
return 301 https://$subfolder.wp.local$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/etc/ssl/certs/wp.crt;
ssl_certificate_key /usr/local/etc/ssl/private/wp.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
server_name ~^(?<subfolder>.+)\.wp.local$;
root html/wp/$subfolder;
index index.php index.html index.htm;
error_log html/wp/error.log notice;
location /wp-content/uploads {
location ~ \.php$ {
deny all;
}
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
}
}
server {
listen 80;
listen [::]:80;
server_name ~^(?<subfolder>.+)\.lav.local$;
return 301 https://$subfolder.lav.local$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/etc/ssl/certs/lav.crt;
ssl_certificate_key /usr/local/etc/ssl/private/lav.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
server_name ~^(?<subfolder>.+)\.lav.local$;
root html/lav/$subfolder/public;
index index.php index.html index.htm;
error_log html/lav/error.log notice;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server {
listen 80;
listen [::]:80;
server_name ~^(?<subfolder>.+)\.test.local$;
return 301 https://$subfolder.test.local$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/etc/ssl/certs/test.crt;
ssl_certificate_key /usr/local/etc/ssl/private/test.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
server_name ~^(?<subfolder>.+)\.test.local$;
root html/test/$subfolder;
index index.php index.html index.htm;
error_log html/test/error.log notice;
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server {
listen 80;
listen [::]:80;
server_name ~^(?<subfolder>.+)\.ntw.local$;
set $server_name_full $subfolder.ntw.local;
root html/ntw/$subfolder/public;
index index.php index.html index.htm;
error_log html/ntw/error.log notice;
location / {
try_files $uri $uri/ @fallback;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SERVER_NAME $server_name_full;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location @fallback {
rewrite ^/(.*)$ /index.php?cbreqpath=$1 last;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment