By resistikat
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;
server_name 52.226.21.217;
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;
}
}
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!
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?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.