Redirect Nginx HTTPS子域重定向
我有几个网站配置了Nginx Nginx/1.10.3 Ubuntu服务器块。浏览以下列出的任何已配置域都能正常工作: 例如,那些配置为使用HTTPS的用户会自动获取HTTP->HTTPS重定向morgrowee.com。问题是当我浏览到一个不存在的子域时,例如:doesnotexist.morgrowe.com。如果我去http://doesnotexist.morgrowe.com,我会被重定向到默认的Nginx页面,这正是我想要的。然而,如果我去https://doesnotexist.morgrowe.com,我被重定向到 这不会太糟糕,但如果我去,我也会被重定向到 在哪里可以找到实现这一点的配置?理想情况下,我希望默认的nginx404页面看起来与http连接一样。我想我必须在/etc/nginx/sites available/default中配置一些东西,但我不知道从哪里开始。以下是我的/etc/nginx/sites available/default文件内容:Redirect Nginx HTTPS子域重定向,redirect,nginx,https,Redirect,Nginx,Https,我有几个网站配置了Nginx Nginx/1.10.3 Ubuntu服务器块。浏览以下列出的任何已配置域都能正常工作: 例如,那些配置为使用HTTPS的用户会自动获取HTTP->HTTPS重定向morgrowee.com。问题是当我浏览到一个不存在的子域时,例如:doesnotexist.morgrowe.com。如果我去http://doesnotexist.morgrowe.com,我会被重定向到默认的Nginx页面,这正是我想要的。然而,如果我去https://doesnotexist.m
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
对http和https使用默认的“Catch All”服务器块,并在服务器名称中使用u只是一个无效值,它永远不会在实际主机上触发 请参见下面链接中的示例
我对Nginx有点陌生。你介意举个例子吗?我应该将这些更改保存在哪个文件中/etc/nginx/sites available/default?我需要您的配置文件来帮助您。我已将/etc/nginx/sites available/default的内容添加到我的原始帖子中。谢谢。哪个服务器块Listen443,从默认配置中只需取消对Listen443行的注释