如何配置 apache 以拒绝直接连接到 IP 地址 ( http://xxx.xxx.xxx.xxx ) 而不是 vhost 名称http://example.com 的连接?
我的虚拟主机配置:
ServerName example.com
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/
<Directory /var/www/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud) 我想通过 获得证书,letsencrypt.sh所以我必须提供关于 HTTP 的挑战。
我已经使用 NGINX 转发到 SSL(在nodejs服务器上提供)。现在我仍然想将所有内容重定向到 SSL,但不是挑战。
这是我的配置
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
server_name screen.example.com;
location /.well-known { }
location / {
return 301 https://$server_name$request_uri;
}
}
Run Code Online (Sandbox Code Playgroud)
打开质询 URL 仍会将我重定向到 HTTPS。
我怎样才能解决这个问题?