I have installed the LEMP stack with this guide and have installed wordpress with this guide. They were both great guides but I need help making a small change.
I want for the root route to reverse proxy into a Node.js server. I would then like the /blog route to serve the wordpress site. As it stands right now the root route servers the wordpress site perfectly.
/etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name my_ip;
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)$ {
expires max;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
How would I modify this Nginx config so that /blog is wordpress and all other routes are handled by a Node.js server?
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!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
@jamesbedont
Start by creating your
/blog
directory and move your data over. Then you’d need to change:to
For the
/
location block, we need to setupproxy_pass
to point to the location of your Node app.Where
http://APP_PRIVATE_IP_ADDRESS:8080
points to your Node App. So for example, if your app is running on:You’d use:
You’d then want to reload NGINX:
or
i can’t access phpmyadmin with this method. i am opening phpmyadmin by typing www.myurl.com/phpmyadmin and www.myurl.com/blog/phpmyadmin. Both not working, Please help me with this
Check this Gist… it works for me ;)
Practically you can copy and paste, just need to update the routes.
https://gist.github.com/yacafx/a730903e8ec69063c18394e4752b6657
Hope this works for you!