在Nginx中配置两个子域

问题描述 投票:-1回答:1

我在Debian 9中使用ovh vps,并在Nginx中使用NodeJS托管不同的项目。

到目前为止,我的项目nodejs正常工作。

但是,我现在想添加一个symfony 4项目。

为此,我使用两个子域:对于NodeJS项目:dev.mydomain.fr对于Symfony4项目:platforme.mydomaine.fr

这是我使用的Nginx配置:

/ etc / nginx / sites-enabled / dev.mydomain.fr:

server {
    listen 80;
    listen [::]:80;

        root /var/www/dev.mydomain.fr/html;
        index index.html index.htm index.nginx-debian.html;

        server_name dev.mydomain.fr www.dev.mydomain.fr;

        client_max_body_size 100M;

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

        location /ping {
                 proxy_pass http://dev.mydomain.fr:3000;
        }
        location /mailgun {
                 proxy_pass http://dev.mydomain:3000;
        }

        location /pma_xxx {
     root /usr/share/;
     index index.php index.html index.htm;

        auth_basic "Restricted Access";
        auth_basic_user_file /etc/nginx/.htpasswd;

     location ~ ^/pma_xxx/(.+\.php)$ {
          try_files $uri =404;
          root /usr/share/;
          fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include /etc/nginx/fastcgi_params;
     }

     location ~* ^/pma_xxx/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
          root /usr/share/;
     }
}

location /phpMyAdmin {
        rewrite ^/* /phpmyadmin last;
    }

}

/ etc / nginx / sites-enabled / plateforme.mydomain.fr:

server {
    server_name plateforme.mydomain.fr www.plateforme.mydomain.fr;
    root /home/myuser/plateformetest/current/public/;
    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }
    # optionally disable falling back to PHP script for the asset directories;
    # nginx will return a 404 error when files are not found instead of passing the
    # request to Symfony (improves performance but Symfony's 404 page is not displayed)
    # location /bundles {
    #     try_files $uri =404;
    # }
    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # optionally set the value of the environment variables used in the application
        # fastcgi_param APP_ENV prod;
        # fastcgi_param APP_SECRET <app-secret-id>;
        # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }
    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }
    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}

因此,两个子域的DNS很好地指向了我的VPS的IP。

关于子域dev.mydomain.fr,它运作良好,但针对我的platform.mydomain.fr子域返回空白页。

您知道我的错误来自哪里吗?谢谢

symfony nginx subdomain
1个回答
0
投票

在查看文件“ /var/log/nginx/project_error.log”后,我对某些文件有版权问题:)

© www.soinside.com 2019 - 2024. All rights reserved.