W
W
WhatIsHTML2018-08-09 08:17:38
Nginx
WhatIsHTML, 2018-08-09 08:17:38

Nginx PHP + NodeJS how to distribute static files?

Hello. PHP and NodeJS are running on the same domain. NodeJS handles requests that go to /node-js, everything else is handled by PHP. I can't figure out how to distribute a static folder from under NodeJS. PHP and NodeJS are in different directories. Here is an example config

server {

    listen 443 ssl;
    server_name   www.example.com;

    root /home/php-project/public;
    index index.php;

    location / {
        autoindex off;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /node-js {
        proxy_pass http://localhost:5555;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    }

} #### End server setup

I tried to link to the NodeJS folder, but all the same, all static files are taken from the PHP folder
location /node-js{
        proxy_pass http://localhost:5555;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
        root /home/node-js;   
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question