By renedahl
I have been following this tutorial on how to install ASP.NET Core 2.1 on Ubuntu. I was able to make an mvc application so far. But i dont know how I can allow remote access from the internet?
Maybe i should allow it from the firewall “ufw”? Allow traffic from port 80?
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!
Hi there,
In order to allow remote access to your web application, you would need to do a few things:
Open Ports in Firewall: If you have a firewall configured (like ufw on Ubuntu), you need to allow incoming traffic on the ports your application is using. In most cases, web applications use port 80 for HTTP and port 443 for HTTPS.
You can open these ports in ufw with the following commands:
sudo ufw allow 80
sudo ufw allow 443
If your application is running on a different port, replace 80/443 with your port number.
Configure Your Web Server: You should have a web server like Nginx or Apache to serve your application. This server should be configured to pass traffic to your .NET Core application. The specifics of this configuration can vary, but here’s an example for an Nginx server block:
server {
listen 80;
location / {
proxy_pass http://localhost:5000; # Replace with your app's bind address
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;
}
}
This configuration tells Nginx to listen on port 80 and pass all incoming traffic to your application running on localhost:5000.
Remember to always ensure your application and server are secure before exposing them to the internet. This includes things like using HTTPS, keeping your software up-to-date, and following best practices for secure coding.
For more information on how to use Nginx as a reverse proxy, you can take a look at the tutorial here:
Best,
Bobby
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.