0

我已经习惯了 nginx 网络服务器应用程序。我总是在通常位于的 nginx conf 文件中设置不同的 server_name/etc/nginx/sites-enabled/

我所做的是我已经设置了服务器,因此它一次可以显示超过 1 个 Web 服务器。我目前有默认和 thecanadiansos 配置文件。

如果用户在浏览器中输入 : thecanadianssos.com ,则表示无法访问服务器 ip。如果用户在浏览器中输入:w.thecanadiansos.com,它会转到默认的 nginx 页面。

用户必须在浏览器中写入:www.thecanadiansos.com才能正常工作。(https似乎运作良好)

我必须如何设置我的 thecanadiansos nginx 配置文件来修复所有问题?系统税没问题,网站正在运行,但文件可能有错误我尝试了很多解决方案,但无法单独找到问题。以下是我目前的情况,希望对您有所帮助,谢谢:)

server {
    server_name thecanadianasos.com www.thecanadiansos.com;
    root /var/www/thecanadiansos;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/www.thecanadiansos.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.thecanadiansos.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server {

 if ($host = www.thecanadiansos.com) {
return 301 https://$host$request_uri;
}

    listen 80;
    server_name thecanadiansos.com www.thecanadiansos.com;
    return 301 https://www.thecanadiansos.com$request_uri;
} ```

4

0 回答 0