Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


nginx configuration to run Nodejs Admin in subfolder with PHP on root?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

nginx configuration to run Nodejs Admin in subfolder with PHP on root?

gurupal_sgurupal_s Member
edited October 2020 in General

I am unable to run my Nodejs admin panel in subfolder. My root directory is running PHP server and I to add Node admin with port 3000 in subdirectory. The below configuration is working but css and images are not loading.

`server {
root /var/www/test.com/html;

index index.php index.html index.htm index.nginx-debian.html;

server_name test.com test.com;

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

location /admin {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}

}`

Comments

  • What's the path of images/css that aren't loading?

    Is that full nginx config or something is left related to static files?

  • dedipromodedipromo Member
    edited October 2020

    Maybe you have to build the static files from source and specify the subdirectory when building. This happened to me a couple of times before when setting up apps or websites written in js or ruby stuff.

  • you don't specifically add block to handle css / images. Does it handled by your nodejs ? it means the image / css must be in admin e.g.

    https://google.com/admin/style.css or https://google.com/admin/logo.jpg

    something like https://google.com/css/style.css just doesn't work, because you doesn't have the block for that.

    Also if it's handled by your nodejs application, make sure it using static (express). nodejs is not like php where you can just create folder and put files there.

  • @alexvolk said:
    What's the path of images/css that aren't loading?

    Is that full nginx config or something is left related to static files?

    It is under admin/public , which is not loading

  • @yokowasis said:
    you don't specifically add block to handle css / images. Does it handled by your nodejs ? it means the image / css must be in admin e.g.

    https://google.com/admin/style.css or https://google.com/admin/logo.jpg

    something like https://google.com/css/style.css just doesn't work, because you doesn't have the block for that.

    Also if it's handled by your nodejs application, make sure it using static (express). nodejs is not like php where you can just create folder and put files there.

    Yes static files are served by Express and it's under admin/public folder. How can i configure this ?

  • @gurupal_s said:

    @yokowasis said:
    you don't specifically add block to handle css / images. Does it handled by your nodejs ? it means the image / css must be in admin e.g.

    https://google.com/admin/style.css or https://google.com/admin/logo.jpg

    something like https://google.com/css/style.css just doesn't work, because you doesn't have the block for that.

    Also if it's handled by your nodejs application, make sure it using static (express). nodejs is not like php where you can just create folder and put files there.

    Yes static files are served by Express and it's under admin/public folder. How can i configure this ?

    You can always Google static files nodejs

Sign In or Register to comment.