I've been trying to host a .NET Core 2.2 application on a Digital Ocean Ubuntu Server using NGINX as a reverse proxy to Kestrel following the Microsoft guide.
Everything seems to work okay, there's no errors in my default-server file, which looks like this
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 / {
try_files $uri $uri/ =404;
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $scheme;
}
}
# Virtual Host configuration for example.com
server {
listen 80;
listen [::]:80;
# these were here by default
root /var/www/example.com;
index index.html
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $scheme;
}
}
I run my application on localhost:5000 using dotnet [MyApplication].dll
at this point there are still no errors but going to PostMan and trying to hit an API via http://<my-server-ip>:80/api/users/new-user
returns a 404:
404 Not Found
404 Not Found
nginx/1.14.0 (Ubuntu)
What am I doing wrong? I'm new to server configuration so please be gentle!!!