symfony - 在nginx中配置两个子域
问题描述
我使用带有 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 子域返回一个空白页。
你知道我的错误来自哪里吗?谢谢
解决方案
查看文件“ /var/log/nginx/project_error.log
”后,我对某些文件有权限问题:)
推荐阅读
- aws-glue - AWS Glue 作业使用来自外部 REST API 的数据
- android - 使用 PDFRender 显示分离的数字签名
- c++ - 使用 std::transform 将 std::vector 容器转换为 std::set
- php - 更新无线电类型的多条记录
- python - 使用 Python 从 Eurostat 提取数据时出现值错误
- exacttarget - Salesforce Markting Cloud (ExactTarget) 的 Rest api 从父业务部门返回类别
- symfony4 - symfony 4.4 + FOSCKEditor + helios-agElfinder 不工作
- string - 如何从 Scala 中的字符串中删除子字符串/字符?
- c# - 从 FileStream 获取元数据
- graphql - GraphQL 错误:Float 类型的可变价格用于预期 float8 的位置