Nginx反向代理多域名的HTTP和HTTPS服务的实现
worker_processes auto;error_log /var/log/nginx/error.log warn;
pid/var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include/usr/local/nginx/conf/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 /var/log/nginx/access.log main;
sendfileon;
tcp_nopushon;
tcp_nodelayon;
upstream dx.exzel.co.nz {
server 127.0.0.1:8080;
}
upstream mybusiness.exzel.co.nz {
server 192.168.1.252:443;
}
server {
listen 80;
server_name dx.exzel.co.nz;
rewrite ^(.*) https://dx.exzel.co.nz permanent;
}
server {
listen 443;
server_name dx.exzel.co.nz;
ssl on;
ssl_certificate /etc/letsencrypt/live/dx.exzel.co.nz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dx.exzel.co.nz/privkey.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/ccieerror.log ;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://dx.exzel.co.nz;
}
}
server {
listen 80;
server_name mybusiness.exzel.co.nz;
rewrite ^(.*) https://mybusiness.exzel.co.nz permanent;
}
server {
listen 443;
server_name mybusiness.exzel.co.nz;
ssl on;
ssl_certificate /etc/letsencrypt/live/mybusiness.exzel.co.nz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mybusiness.exzel.co.nz/privkey.pem;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/mybusiness.log ;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://mybusiness.exzel.co.nz;
}
}
server {
listen 80;
server_name www.empnz.co.nz empnz.co.nz;
location / {
proxy_pass http://192.168.1.15 ;
}
}
}
文档来源:服务器之家http://www.zzvips.com/article/80246.html
页:
[1]