Unable to server static files in both wordpress and nodejs in nginx server simultaneously.

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;


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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?