局域网Nginx域名设置

局域网Nginx域名设置

我的 Linux 机器上运行着一个 Web 应用程序,可以通过 IP 地址 xxxx:3001 在所有其他网络机器上访问该应用程序。我想使用像 myfun.fun 这样的域名,以便可以通过该域名在整个网络中访问它。我是 Nginx 的新手,有人可以告诉我我实际上需要做什么才能实现这一目标吗?

答案1

在 Apache 中,您可以将其称为vhost. Nginx 实际上没有这个,它被称为服务器块。

您可以在文档中阅读更多内容https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/

具体来说,您需要将其添加到您的配置中:

  server {
    server_name myfun.fun;
    access_log logs/myfun.fun.access.log main;

    root /var/www/myfun.fun/htdocs;
  }

当然,您需要注册域名 myfun.fun 并提供指向您的 nginx 服务器的 DNS 记录。

相关内容