@echo off
start /D%cd% nginx.exe
@echo off
start /D%cd% nginx.exe -s quit
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#Server 1
server {
listen 80;
server_name server1.site.com;
#Redirect to HTTPS
location / {
proxy_pass http://10.0.0.1:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
#Server 2
server {
listen 80;
server_name server2.site.com;
#Redirect to HTTPS
location / {
proxy_pass http://10.0.0.2:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
server {
server_name server1.site.com;
root /var/www/server1.site.com/public;
# reverse proxy
location / {
proxy_pass http://10.0.0.1:80;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name server1.site.com;
root /var/www/server1.site.com/public;
# SSL
ssl_certificate /etc/letsencrypt/live/server1.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server1.site.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/server1.site.com/chain.pem;
# security
include nginxconfig.io/security.conf;
# reverse proxy
location / {
proxy_pass http://10.0.0.1:80;
include nginxconfig.io/proxy.conf;
}
# additional config
include nginxconfig.io/general.conf;
}
# subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name *.server1.site.com;
# SSL
ssl_certificate /etc/letsencrypt/live/server1.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server1.site.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/server1.site.com/chain.pem;
return 301 https://server1.site.com$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .server1.site.com;
include nginxconfig.io/letsencrypt.conf;
location / {
return 301 https://server1.site.com$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name server2.site.com;
root /var/www/server2.site.com/public;
# SSL
ssl_certificate /etc/letsencrypt/live/server2.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server2.site.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/server2.site.com/chain.pem;
# security
include nginxconfig.io/security.conf;
# reverse proxy
location / {
proxy_pass http://10.0.0.2:80;
include nginxconfig.io/proxy.conf;
}
# additional config
include nginxconfig.io/general.conf;
}
# subdomains redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name *.server2.site.com;
# SSL
ssl_certificate /etc/letsencrypt/live/server2.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server2.site.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/server2.site.com/chain.pem;
return 301 https://server2.site.com$request_uri;
}
# HTTP redirect
server {
listen 80;
listen [::]:80;
server_name .server2.site.com;
include nginxconfig.io/letsencrypt.conf;
location / {
return 301 https://server2.site.com$request_uri;
}
}