本人的配置是
liunx centerOS8
nginx 1.14.1
开启多域名
# 反向代理至8080端口
server
{
listen 80;
server_name x1.com;
location / {
proxy_redirect off;
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://localhost:8080; # 代理端口
}
}
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /xxx/xxx; # 我这里是放vue项目的、请根据实际情况写
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server
{
listen 80;
server_name x2.com;
location / {
proxy_redirect off;
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://localhost:8081;
}
}
server {
listen 8081 default_server;
listen [::]:8081 default_server;
server_name _;
root /xxx/xxx;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
多个ssl证书
先确定是否开启
nignx -V
# 如果是TLS SNI support disable那你需要重新编译下Nginx,如果enable了,你直接修改配置文件就行
WechatIMG129.jpeg
server {
listen 443 ssl;
server_name x3.com;
ssl_certificate xxx.pem;
ssl_certificate_key xxx.key;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:10000; # 我这里端口只是用作接口的
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
server {
listen 443 ssl;
server_name x4.com;
root xxx/xxxx/; # 我这里是放vue项目的
ssl_certificate xxx.pem;
ssl_certificate_key xxx.key;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;
location / {
# proxy_pass http://localhost:10000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
网友评论