Sup*_*ber 2 nginx proxypass node.js web
大家好,我有一台 Rasberry Pi 4,我希望使用 Nginx 托管多个 node.js 网站,现在我有一个运行良好并连接到 Cloudflare 的实例。
下面是当前的“默认”文件
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:5085;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要在这里托管另外 2 个网站,它们是 - 在 localhost:3000 上运行的 example1.com和 在 localhost:4000 上运行的 example2.com
现在,在此之后,我又有了一个疑问,我需要将这两个添加到 Cloudflare 中。

在图一中,我只需输入我的公共 IP 地址,该地址是端口 80 的端口转发,这是该图的图像

现在我如何将主机连接到cloudflare。有人可以帮忙吗?
您只需复制当前的 nginx 服务器配置并将 server_name 属性更改为server_name example2.com并proxy_pass相应地更改目标。
它看起来像这样:
# example.com server/proxy
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:5085;
# ...
}
}
# example2.com server/proxy
server {
listen 80; # we removed the default_server tag here
listen [::]:80; # because it can only be used once
server_name example2.com www.example2.com;
location / {
proxy_pass http://localhost:1234;
# ...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2081 次 |
| 最近记录: |