locked
Is there a way to make blazor allow outside http access? RRS feed

  • Question

  • User2061382913 posted

    (Copy pasted this from stack overflow, got no answer there.)

    I just got started with Blazor, following [Microsoft's Guide,][1] but I need to allow outside access from http, so I can access it from ```<server-ip>:5000```, as I am running a linux VPS that I don't have GUI access to. Is there any way to do this? (When creating my Blazor app, I left out the ```--no-https```) Sorry if this is a dumb question. [I looked it up on google][2] and found nothing helpful to me.  
    I get this:
    [![This is the error][3]][3]
    When I run ```dotnet run```  
    If you're wondering which version of Blazor I'm running (WASM or Server), I don't know. I'm just following Microsoft's guide.

      [1]: https://dotnet.microsoft.com/learn/aspnet/blazor-tutorial/run
      [2]: https://www.google.com/search?q=how%20to%20allow%20outside%20blazor%20access&oq=how%20to%20allow%20outside%20blazor%20access&aqs=chrome..69i64j69i57.2200j0j9&sourceid=chrome&ie=UTF-8&safe=active
      [3]: https://i.stack.imgur.com/xAgUw.png

    Thursday, January 14, 2021 9:26 PM

Answers

  • User-474980206 posted

    Generally neither port 5000 or the ssl 5001 port are open to external browsers. You will need to open the firewall. See your Linux docs for this. Remove the httpsrediect option in startup if you don’t want ssl redirection forced.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 14, 2021 10:41 PM

All replies

  • User-474980206 posted

    Generally neither port 5000 or the ssl 5001 port are open to external browsers. You will need to open the firewall. See your Linux docs for this. Remove the httpsrediect option in startup if you don’t want ssl redirection forced.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 14, 2021 10:41 PM
  • User2061382913 posted

    Can I change the port to something like 8080 or 8000?

    Friday, January 15, 2021 1:30 AM
  • User-474980206 posted

    Yes. You can set it in appsettings.json or the command line. It all depends on how you are launching the app.

    Friday, January 15, 2021 3:40 PM
  • User2061382913 posted

    How would I do it from appsettings.json? I opened it in nano, and this is what I got. Nothing about the port:


      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "AllowedHosts": "*"
    }

    thanks for helping me with my newbie questions

    Friday, January 15, 2021 5:48 PM
  • User-474980206 posted
    { 
       "Urls": "http://localhost:80" 
    }
    

    Friday, January 15, 2021 8:57 PM