Question
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;
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;
}
}
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.
×