如何在nginx中向http:// <public_ip>和https:// <public_ip>发送请求?

我有一些网站,每个都在nginx自己的服务器块中,其域名在server_name指令中定义。 其中一个网站也有一个https服务器{}块。 他们都在同一个IP。

我如何创build服务器块,将请求到http://1.2.3.4 https://1.2.3.4 ,而不是任何域? 我已经尝试过创build“默认”服务器的变体,但是如果nginx看到一个默认的https块,它只是使用该块用于所有的https连接,包括拥有自己的https服务器块的网站。

Ubuntu 12.04上的nginx 1.4.2。

谢谢你的帮助。

有关nginx vhost的介绍,请参见http://nginx.org/en/docs/http/request_processing.html#mixed_name_ip_based_servers

只要你只有一个IP地址的SSL网站,default_server设置就可以正常工作:

 server { listen xxxx:443; } 

nginx目前不支持SNI,这将允许您为单个IP地址指定多个SSL证书: http : //nginx.org/en/docs/http/configuring_https_servers.html#compatibility