By DaZibion
Hi there,
I was following the tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
Where they set up Nginx as a reverse Proxy server. I tried serving a second simple node application on port 7474.
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('Hello There!')
})
app.listen(7474, function() {
console.log('listening on port 7474')
})
I followed the tutorial and added a second location to my /etc/nginx/sites-available/default File
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:8080;
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 /neo4j {
proxy_pass http://localhost:7474;
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;
}
}
When accessing my server under http://123.45.6.789/neo4j results in a 404 error.
What am I doing wrong?
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!
I think this may be an easy fix. You can learn about how Nginx parses your configuration here.
Nginx will serve the first match it encounters. Since /neojs matches the / location block (it is located under this directory) this location block is used to handle the request.
If you place your /neojs location block above your / location block, requests for locations in /neojs will now match the correct location block and all other requests would filter down to the other block.
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.