使用Nginx并行运行PHP和React

时间:2019-02-06 17:38:29

标签: php reactjs nginx

我对Docker,Nginx等相对较新,并且一直在寻找解决方案的日子,但没有找到解决方案。我正在从一个堆栈过渡到另一个堆栈,因此在重构时需要保留现有功能。我正在尝试使用Nginx并排运行PHP和React,其中包含/ php /的路由将显示PHP,其他所有内容将运行React:

server {
    server_name _;
    listen 80;
    root /var/www;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;

    location /php/ {
        #try_files $uri =404;
        alias /var/www;
        index index.php index.html;
        try_files $uri $uri/ /index.php?q=$uri&$args;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location / {
        root /react-app;
        try_files $uri $uri/ /index.html;
        default_type "text/html";

        #proxy_pass http://localhost:3000;
        #proxy_http_version 1.1;
        #proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection 'upgrade';
        #proxy_set_header Host $host;
        #proxy_cache_bypass $http_upgrade;
    }
}

我不断收到禁止的错误和内部服务器错误。有什么想法可以做到这一点吗?

注意:我在没有Nginx的情况下就在本地运行了所有这些容器,但是没有问题,但是由于我们是如何设置服务器的(每个容器都有自己的子域),所以当我将它们放在Portainer上时,我需要配置Nginx。

Console error output

0 个答案:

没有答案