So I have my main site that's built with react and express. Now I want to add a blog part to my site that's built with next.js. However I don't want to host it on something like blog.example.com
I would rather host it on example.com/blog
.
I'm using a digital ocean droplet that's running ubuntu 18.04 and nginx. I've looked at similar questions as mine but I couldn't get this working. I've pasted my nginx config below and added a code mark to the location block not working.
server {
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name example.com; # managed by Certbot
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_max_temp_file_size 0;
proxy_pass http://my_nodejs_upstream/;
proxy_redirect off;
proxy_read_timeout 240s;
}
location /api {
proxy_pass http://localhost:3001;
}
# THIS BLOCK IS NOT WORKING
location /blog {
root /blog; # /blog dir is in the root folder
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
I'm pretty new to nginx configuration so apologies if this is a simple mistake. Thank you.