ube*_*ebu -2 ssl nginx virtualhost apache-2.2
我正在尝试通过 apache 或 nginx 虚拟主机设置多个 https 网站,但我注意到我必须将端口附加到 IP 地址的末尾才能查看使用非默认 443 ssl 端口的网站的 https
是否可以在同一台服务器上使用不同的端口拥有多个 https 网站?如果是,那么如何才能做到这一点而不需要在末尾附加非默认端口
我尝试过什么
# Ensure that Apache listens on port 80 and all ssl ports
Listen 80
Listen 443
Listen 543
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
NameVirtualHost *:443
NameVirtualHost *:543
<VirtualHost 192.168.101.44:443>
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here
</VirtualHost>
<VirtualHost 192.168.101.54:543>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
按此顺序,将能够分别访问https://www.example1.com和https://www.example2.org上的网站
这可能吗?阿帕奇?nginx?我使用这两个网络服务器,所以想知道它是否可以与其中一个或两个一起使用。如果需要,我可以将问题编辑得更清楚。
谢谢
您可以在一台服务器上使用一个 IP 地址提供任意数量的站点,并且每个域都可以侦听端口 80 和 443。因此 example.com 可以侦听 80/443,example1.com 可以侦听 80/ 443等
在 nginx 中你只需定义多个服务器,如下所示
server {
server_name www.example.com;
listen 80;
listen 12345;
listen 443 ssl;
location / {
# whatever
}
}
server {
server_name www.example1.com;
listen 80;
listen 443 ssl;
location / {
# whatever
}
}
# This server simply redirects the requested to the https version of the page
server {
listen 80;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
您最好从 80 转发到 443,这样一切都是安全的。我在本教程中有一套非常完整的配置文件,并且一般来说还有很多关于 nginx 的配置文件。
请注意,有人建议直接编辑我教程的另一部分。我直接链接到该页面,因为它包含整个系列教程的目录,以及您可以下载的 nginx 配置文件。
归档时间: |
|
查看次数: |
9586 次 |
最近记录: |