Windows VM无法通过公共IP地址访问

时间:2018-07-09 07:04:52

标签: windows azure nginx azure-virtual-network

我有azure Windows Server 2016 VM,已经安装了nginx服务器来运行php网站。它使用私有IP地址和本地主机运行,但不能使用公共IP地址。

我在入站端口规则中启用了端口80 Inbound port rules

我的nginx配置是:

server {
    listen       <my public IP>:80;
    location / {
        root   html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  C:/nginx-1.14.0/html$fastcgi_script_name;
        include        fastcgi_params;
    }
}

1 个答案:

答案 0 :(得分:1)

首先,您可以像这样更改nginx配置文件:

server {
    listen      80;
    server_name example.org www.example.org(not ip address);
    ...
    }

然后,您可以使用VM上的命令netstat -a检查端口80是否正在侦听。另外,请查看VM侧防火墙配置中端口80是否打开。

完成上述步骤后,使用客户端上的telnet publicipaddress 80验证网络连接是否正常。

如果telnet的结果正常,则可以尝试再次使用公共IP地址运行php网站。

有关更多参考,请参见How nginx processes a request

相关问题