📣读完这篇文章里你能收获到
- Nginx实现同端口代理多项目
- Nginx实现同项目多端口配置
一、Nginx同一个端口代理多个项目
# 项目A
server {
listen 80;
server_name www.a.com;
location / {
try_files $uri $uri/ /index.html;
root /opt/epidemic_platform/app;
index index.html index.htm;
}
}
# 项目B-与项目A同80端口
server {
listen 80;
server_name www.B.com;
location / {
try_files $uri $uri/ /index.html;
root /opt/epidemic_platform/web;
index index.html index.htm;
}
}
二、Nginx同项目多端口代理
# 项目A-80端口
server {
listen 80;
server_name www.a.com;
location / {
try_files $uri $uri/ /index.html;
root /opt/epidemic_platform/app;
index index.html index.htm;
}
}
# 项目A-443端口
server {
listen 443 ssl;
server_name www.a.com;
ssl_certificate /Website/00Cert/xxx.com.pem;
ssl_certificate_key /Website/00Cert/xxx.com.key;
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;
location / {
try_files $uri $uri/ /index.html;
root /opt/epidemic_platform/app;
index index.html index.htm;
}
}