【问题标题】:Nginx how to serve simple http website on a different portNginx 如何在不同的端口上提供简单的 http 网站
【发布时间】:2021-01-17 02:43:34
【问题描述】:

我有 nginx 和两个简单​​的静态站点(每个站点一个 index.html)。 我想实现另一个站点在不同的端口可用,如下所示:

http://example.com -> served from /etc/share/nginx/html/site1/index.html

http://example.com:12345 -> served from /etc/share/nginx/html/site2/index.html

我在非 80 端口上试过这样:

server {
   listen 12345;
   server_name example.com;
   root /usr/share/nginx/html/site2;

   location / {
      index index.html;
   }
}

我该怎么做? 谢谢!

【问题讨论】:

    标签: http nginx port


    【解决方案1】:

    抱歉,已解决,我必须在防火墙上启用端口(我在 CentOS 8 上):

    firewall-cmd --zone=public --add-port=12345/tcp --permanent
    firewall-cmd --reload
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-17
      • 2018-10-07
      • 2018-11-16
      • 1970-01-01
      • 2017-01-21
      • 2017-10-16
      • 1970-01-01
      • 2022-01-20
      相关资源
      最近更新 更多