指向GCE的IP地址的子域名

我有一个问题,我近两个月来一直无法解决。 我已经build立:

  • 在GoDaddy帐户的子域名中,我创build了Alogging并将其指向IP地址。

我的GCE实例的地址…我想我的Nginxconfiguration没问题。 我的问题是,当我访问我的网站的URL,它会显示IP地址,而不是mysubdomain.example.com 。 我不想让我的IP地址显示我想要在浏览器中可见的URL中的子域名。 我的疑问是我的laravel应用程序的.htaccess导致IP地址始终显示在URL中。

在老爹帐户,这是我如何创build在DNSpipe理。

 type=A, Host=mysubdomain, Point to=ip address, ttl=1. 

也在下面有子域的转发部分,我点击添加button,我inputmysubdomain,转发到http:// ip地址,forwrd type = permanent(301),settings =只转发

这是我的服务器GCE中的Nginxconfiguration

  server { listen 80; listen [::]:80; root /var/www/pro1/public/; # Add index.php to the list if you are using PHP index index.php index.html index.htm; server_name mysubdomain.example.com; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.php?$query_string; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } 

还有下面有子域的转发部分,我点击添加button,我inputmysubdomain,转发到http://ip地址,转发types=永久(301),设置=只转发

那就是问题所在。 当您已经configurationAlogging时,您不需要外部redirect ! 这是两件不同的事情。

(虽然有一个Alogging(对外部服务器),你不一定会看到redirect – 但这可能是GoDaddy的实施?)

删除redirect(“转发部分”)。

您将需要清除您的浏览器caching,因为错误的301(永久)redirect将被浏览器caching(对于访问过您的网站的任何用户,这是相同的)。

的确,它应该是Laravel应用程序级别的redirect。 没有nginx的规则看起来是这样做的,而且……你似乎感到困惑; nginx不关心.htaccess文件。 看看这个 ,例如。