我的问题与那里的数千个类似问题完全不同。
我有 2 台专用服务器。更强的是服务MyMainDomain.com
我较弱的服务器但巨大的硬盘驱动器托管MyOtherDomain.com以及上面我的主域的子域中的图像,可以说:sub.MyMainDomain.com。该服务器有 2 个 IP。如果MyOtherDomain.com和 sub.MyMainDomain.com都在同一个 IP 上侦听,则MyOtherDomain.com将中断。如果在不同的 IP 上收听就解决了......但那是不对的!我们需要他们都在 1 个 IP 上工作。
Nginx version: nginx/1.13.8
Run Code Online (Sandbox Code Playgroud)
/etc/nginx/sites-enabled 中的符号链接:
我的其他域
server {
listen IP_1:443 ssl http2;
server_name MyOtherDomain.com; # this domain must match Common Name (CN) in the SSL certificate
...........
# pass all requests to Meteor
location / {
proxy_pass http://127.0.0.1:3000;
Run Code Online (Sandbox Code Playgroud)
sub_MyMainDomain
server {
listen IP1:443 ssl; # error
listen IP2:443 ssl; # work fine
server_name sub.MyMainDomain.com ;
# proxy pass to minio
location / {
proxy_set_header Host $http_host;
proxy_pass http://IP1 or IP2:9000;
}
Run Code Online (Sandbox Code Playgroud)
配置文件
server { # this block is useless, googling sometime does not help
listen 443 ssl default_server;
listen [::]:443 ssl default_server; # not sure if you want/need it here as well. Try both ways.
server_name _;
return 444;
}
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
Run Code Online (Sandbox Code Playgroud)
}
所有域都受具有分配 IP 的 cloudflare DNS 保护:
MyMainDomain.com : IP_0
MyOtherDomain.com 和 sub.MyMainDomain.com 共享 IP_1 优先
其他地方需要 IP_2
不要听IP。只需监听所有地址。例如:
server {
listen 443 ssl http2;
server_name MyOtherDomain.com
}
server {
listen 443 ssl http2;
server_name sub.MyOtherDomain.com
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
991 次 |
最近记录: |