Report this

What is the reason for this report?

How to enable webaccess to a webapplication running on .netcore installation on ubunto 18.4

Posted on December 1, 2018

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?

https://odan.github.io/2018/07/17/aspnet-core-2-ubuntu-setup.html?fbclid=IwAR3X9eWJoDPo8y0_r5U-CBrdmOiSnvdHGfgZOkk6201b5GiZw1Rq3tBk8_w



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.

Hi there,

In order to allow remote access to your web application, you would need to do a few things:

  1. 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.

  2. 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:

https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-on-ubuntu-22-04

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.