子域始终重定向到主域

时间:2019-10-02 03:51:03

标签: wordpress nginx

我想设置我们Wordpress网站的暂存版本,所以我复制了所有内容,添加了新的nginx配置,并将子域指向服务器(所有子域都位于同一ubuntu服务器上)。

我在staging.mydomain.com中添加了基本身份验证,当我转到任何计算机(隐身)上的URL时,都会看到auth登录弹出窗口,但是当我填写它时,我将直接重定向到mydomain。 com。我以前有这个确切的问题,这是一个缓存问题,但是我不认为这是事实,这就是为什么我认为我的Nginx配置中缺少某些内容。

这是主要网站的nginx配置:

limit_req_zone $binary_remote_addr zone=one:10m rate=14r/s;
limit_req_zone $binary_remote_addr zone=login:10m rate=2r/s;

server {
    listen 80;
    server_name mydomain.com www.mydomain.com;
    rewrite        ^ https://$server_name$request_uri? permanent;
}

server {
     listen 443;

     server_name mydomain.com www.mydomain.com;

     root /var/www/mydomain;

     index index.php;


     location = /wp-login.php {
         limit_req   zone=login  burst=5 nodelay;
         include fastcgi_params;
         fastcgi_intercept_errors on;
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/run/php/php7.0-fpm.sock;
     }

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

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

     location / {
             try_files $uri $uri/ /index.php?$args;
             proxy_read_timeout 300;
     }

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
     }

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

     ssl     on;
     ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
     keepalive_timeout   70;

     ssl_prefer_server_ciphers On;
     ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
     ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;

}

这是staging.mydomain.com的Nginx配置:

server {
    listen 80;
        server_name staging.mydomain.com www.staging.mydomain.com;
    rewrite        ^ https://staging.mydomain.com$request_uri? permanent;
    return 301  https://staging.mydomain.com;
}

server {
    listen 443;

    server_name staging.mydomain.com www.staging.mydomain.com;

        root /var/www/mydomain-staging;

        index index.php index.html;

        auth_basic          "Admin Area";
        auth_basic_user_file    /etc/apache2/.htpasswd;

    location = /wp-login.php {
        limit_req   zone=login  burst=5 nodelay;
            include fastcgi_params;
            fastcgi_intercept_errors on;
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

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

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

        location / {
                try_files $uri $uri/ /index.php?$args;
        proxy_read_timeout 300;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

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

    ssl     on;
    ssl_certificate /etc/letsencrypt/live/staging.mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/staging.mydomain.com/privkey.pem;
    keepalive_timeout   70;

    ssl_prefer_server_ciphers On;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;

}

0 个答案:

没有答案