I am trying to setup a nodejs frontend and a wordpress blog along with it for CMS on Nginx. The wordpress site would run at /blog. My wordpress site is installed in /var/www/wordpress and my nodejs application is installed in /home/Smarsolar/floatingsolar. The problem is I am unable to serve static files in both of them. Its either working in wordpress or in Node server. I am attaching my nginx configuration file Any help would be appreciated.

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

        root /var/www/wordpress;
        index index.php index.html index.htm index.nginx-debian.html;

        location = /favicon.ico { log_not_found off; access_log off; }
        location = /robots.txt { log_not_found off; access_log off; allow all; }
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {


        location / {
        root /home/Smartsolar/floatingsolar;
            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;


        location /blog {
                # alias /home/apps/myapp;
                try_files $uri $uri/ /index.php$is_args$args;
        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;

        location ~ \.php$ {
                # If php is updated, should update the fpm php version
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.2-fpm.sock;

        location ~ /\.ht {
                deny all;

edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Hello, @resistikat

As long as the path you have listed is correct this should work. I would recommend checking to ensure that the files and directory will allow the www-data user (which nginx is running as) is able to view files in that location.

Could you please let me know what error you get when you try to load a static file?

Submit an Answer