如何将我的服务器的IP地址重定向到域名?

问题描述 投票:1回答:1

我将Drupal 8站点从Apache服务器迁移到Nginx服务器。域名显示该站点,但IP地址不会重定向到域名。

这该怎么做 ?

我是否必须保留此IP地址或输入我的IP地址?

我测试了这个块,它显示错误:

server {
listen 80;
listen [::]:80 ipv6only=on;
server_name domaine.com;
return 301 $scheme://www.domaine.com$request_uri;
root /var/www/www-domaine-com/web;

sudo nginx -t

nginx: [warn] conflicting server name "domaine.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "domaine.com" on [::]:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx ip virtualhost drupal-8 ubuntu-18.04
1个回答
0
投票

您需要将更改回滚到正常工作的解决方案,因为您当前的配置看起来完全破坏了您的网站。在第一个server块的顶部,以下行似乎是虚假的并且需要删除:

listen 80;
listen [::]:80 ipv6only=on;
return 301 $scheme://www.s1biose.com$request_uri;

您的网站使用https访问,无法通过IP地址联系,大多数浏览器都不会抱怨证书无效。

但是,您可以通过将一行http更改为return 404; # managed by Certbot,轻松安排将所有return 301 https://example.com$request_uri;连接重定向到您的站点。

以上假设您的配置中没有其他server块。您可以使用nginx -T(大写“T”)在Nginx看到它的所有包含文件时打印整个配置。

© www.soinside.com 2019 - 2024. All rights reserved.