0

我对 Nginx 相当陌生,我正在尝试在我的服务器上运行 WordPress 和 Yourls。我在我的 conf.d 中使用了两个服务器块,以及不同的 server_name 和不同的端口。但是当我进入我的 Yourls 网站时,我仍然会进入我的 WordPress 网站。这是我的 WordPress .conf 文件。

server {
    listen   80;
    server_name www.wp_domain.com wp_domain.com;
    rewrite ^(.*) https://$server_name$1 permanent;
}

server {
    listen 443 ssl;
    server_name www.wp_domain.com wp_domain.com;
    charset utf-8;

    ssl_certificate /etc/nginx/ssl/fullchain.cer;
    ssl_certificate_key /etc/nginx/ssl/wp_domain.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_ecdh_curve secp384r1;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_session_tickets off;
    keepalive_timeout 70;

    set $host_path "/var/www/wp_domain";
    access_log  /var/log/nginx/wp_domain.com.access.log  main buffer=32k flush=30s;
    error_log /var/log/nginx/wp_domain.com.error.log;

    root   $host_path;

    set $skip_cache 0;
    if ($query_string != "") {
        set $skip_cache 1;
    }
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|sitemap(_index)?.xml") {
        set $skip_cache 1;
    }
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }

    location = / {
        index  index.php index.html;
        try_files /index.php?$args /index.php?$args;
    }

    location / {
        index  index.php index.html;
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ ^/\.user\.ini {
            deny all;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_index index.php;
        fastcgi_cache wordpress;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
    location ~ \.(js|css|png|jpg|jpeg|gif|ico|swf|webp|pdf|txt|doc|docx|xls|xlsx|ppt|pptx|mov|fla|zip|rar)$ {
        expires max;
        access_log off;
        try_files $uri =404;
    }
}

这是我的 Yourls .conf 文件。

server {
    listen   80;
    server_name www.ys_domain.com ys_domain.com;
    charset utf-8;

    root "/var/www/YOURLS";

    location / {
        index  index.php index.html;
        try_files $uri $uri/ /yourls-loader.php$is_args$args;
    }

    location ~ ^/\.user\.ini {
            deny all;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9100;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

我也有 ys_domain.com 的证书,并且想将 ssl 部分放在 yourls .conf 中,就像在 wordpress .conf 中一样。但它没有用,所以我删除了它。希望有人能帮我找出错误。或者我应该在这里粘贴 nginx.conf 吗?

4

0 回答 0