nginx保持重定向到ip而不是子域

时间:2017-03-20 20:46:34

标签: wordpress nginx google-compute-engine

我的nginx配置如下(我的意思是从https://codex.wordpress.org/Nginx#General_WordPress_rules复制)

    # HTTP server
upstream php {
        server unix:/opt/bitnami/php/var/run/www.sock;
        server 127.0.0.1:9000;
}

server {
        ## Your website name goes here.
        server_name [sub.domain.com];
        #return 301 http://[sub.domain.com]$request_uri;
        ## Your only path reference.
        root /opt/bitnami/nginx/html;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }


        location ~ /.well-known {
                allow all;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break w$
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

}

我还添加了以下DNS记录: enter image description here

但是如果我在浏览器中输入[sub.domain.com],我仍然会被重定向到IPADDRESS。我的.conf有什么问题?

我正在使用Google Cloud Compute Engine作为主机。

0 个答案:

没有答案