Setup ASP.NET on Linux Server
Hello,
i have a problem i tried to run a ASP.NET Project from a Linux Server but everytime when i try to realch the IP with the Port 5000 it seems like to refuse the connection i don't get any Error Exceptions or anything
im using Apache2 Server
63 Replies
Sorry for the German
the ASP.NET project listening for
localhost
, so only IP addresses like 127.0.0.1
and ::1
or other configured loopback addresses.I also made sure that this project works on my local project
But isn’t this localhost?
I looked into the docs and it said
yes, but if u for example use some kind of
192.168.0.xxx
ip to reach it, u will receive a connection refuseohhh how would i set this up
in my launchSettings is everything on Production and the IP 127.0.0.1
but i didn't copyied the File over
well, first of all the question is how u want it to run, u could run it standalone/in docker to reach the app directly or u could use apache or similar web servers as reverse proxies
i want to run it as standalone
sec, been eternities since i ran such stuff standalone, so i need to find how to configure it quickly
this has everything in it to configure it in multiple ways
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-8.0
Configure endpoints for the ASP.NET Core Kestrel web server
Learn about configuring endpoints with Kestrel, the cross-platform web server for ASP.NET Core.
kinda confusing for me as beginner
Imma take a look
what is the safest way?
i want to make a oAuth system with it
i never touched oauth so i cant say anything about that, but the easiest way would probably using the appsettings.json
so something like
well
5000
as port in ur casehow would i set this up in my code ?
will this auto regonize everything?
or do i not have to code anything?
Kestrel can load endpoints from an IConfiguration instance. By default, Kestrel configuration is loaded from the Kestrel section and endpoints are configured in Kestrel:Endpoints:this basically means u would just have to add it to ur
appsettings.json
without having to touch any code
so u wouldnt even call builder.WebHost.ConfigureKestrel(...)
at allit's still not working
same error
on that linux machine, can u reach the app via that IP and
localhost
?i onyl have Linux on Console not on Remote Based
or wait you mean if i should ping it?
Seems like not
what do u mean by "linux on console"?
like via SSH
Sorry
is that a completely remote machine or is it in ur local network, just a different computer?
so a vps or a root server. could be that the ping service is simply disabled then
i would try after using ssh to get shell access to use curl or wget or something similar to try reaching the server from that machine directly
what do you mean by that?
Like place a random file and then i do wget ip:5000/Home/Secret
something like that
just the base url so
http://localhost:5000
and http://<the-ip-address>:5000
and do u see logs in the app console now?
yes i do
and for the global ip?
i see something too
the app logs?
well idm i show my ip now
:skull_cry:
do u use the same ip to ssh into the kvm from ur local machine?
yes
then something with the firewall configuration of the kvm seems to be off, but there i dont have any experience
i did "sudo ufw allow 5000" that should allow the 5000 to be open i guess
what does
sudo ufw status | grep 5000
yield?Nothing
what does just
sudo ufw status
yield? seems like the firewall isnt correctly configuredi guess this is not good
nope 😂
:skull_cry:
but when i enable it everything will f up
might be, lets check
iptables
directly first as ufw
is using that under the hood
sudo iptables -L -n -v
this will probably be quite longquite long is something else i guess
:skull_cry:
iptables --list
?yeah it seems its completely unconfigured or the system is using something else as firewall
basically here its becoming dangerous, if u configure the firewall wrong and activate it u might lock urself out
oh no
this is bad
i would install some virtual machine software like virtual box, create a local virtual machine and set it up like u have ur kvm
and from there u can then play around on that thing how to configure it correctly
oh no
more work :pepe_Sad:
but when the Firewall is inactiv then i would connect into the ASPNET
thats indeed true 🤔
yes
maybe just ask their support which firewall is in use because u cant access ur server at port 5000 but at the ssh port
it seems like that i don't have a external firewall