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
No description
No description
No description
63 Replies
ඞ Straßenfeger ඞ
Sorry for the German
cap5lut
cap5lut7mo ago
the ASP.NET project listening for localhost, so only IP addresses like 127.0.0.1 and ::1 or other configured loopback addresses.
ඞ Straßenfeger ඞ
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
cap5lut
cap5lut7mo ago
yes, but if u for example use some kind of 192.168.0.xxx ip to reach it, u will receive a connection refuse
ඞ Straßenfeger ඞ
ohhh 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
cap5lut
cap5lut7mo ago
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
ඞ Straßenfeger ඞ
i want to run it as standalone
cap5lut
cap5lut7mo ago
sec, been eternities since i ran such stuff standalone, so i need to find how to configure it quickly
cap5lut
cap5lut7mo ago
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.
ඞ Straßenfeger ඞ
kinda confusing for me as beginner Imma take a look what is the safest way? i want to make a oAuth system with it
cap5lut
cap5lut7mo ago
i never touched oauth so i cant say anything about that, but the easiest way would probably using the appsettings.json so something like
{
"Kestrel": {
"Endpoints": {
"LocalEndpoints": {
"Url": "http://localhost:8080"
},
"NetworkEndpoints": {
"Url": "http://192.168.0.123:8080" // add the correct IP here
},
}
}
}
{
"Kestrel": {
"Endpoints": {
"LocalEndpoints": {
"Url": "http://localhost:8080"
},
"NetworkEndpoints": {
"Url": "http://192.168.0.123:8080" // add the correct IP here
},
}
}
}
well 5000 as port in ur case
ඞ Straßenfeger ඞ
how would i set this up in my code ?
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
{
var kestrelSection = context.Configuration.GetSection("Kestrel");

serverOptions.Configure(kestrelSection)
.Endpoint("HTTPS", listenOptions =>
{
// ...
});
});
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
{
var kestrelSection = context.Configuration.GetSection("Kestrel");

serverOptions.Configure(kestrelSection)
.Endpoint("HTTPS", listenOptions =>
{
// ...
});
});
will this auto regonize everything? or do i not have to code anything?
cap5lut
cap5lut7mo ago
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 all
ඞ Straßenfeger ඞ
it's still not working same error
cap5lut
cap5lut7mo ago
on that linux machine, can u reach the app via that IP and localhost?
ඞ Straßenfeger ඞ
i onyl have Linux on Console not on Remote Based or wait you mean if i should ping it?
ඞ Straßenfeger ඞ
Seems like not
cap5lut
cap5lut7mo ago
what do u mean by "linux on console"?
ඞ Straßenfeger ඞ
like via SSH Sorry
cap5lut
cap5lut7mo ago
is that a completely remote machine or is it in ur local network, just a different computer?
ඞ Straßenfeger ඞ
it's a compleatly remote mashine from https://deinserverhost.de/ a KVM
cap5lut
cap5lut7mo ago
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
ඞ Straßenfeger ඞ
what do you mean by that? Like place a random file and then i do wget ip:5000/Home/Secret something like that
cap5lut
cap5lut7mo ago
just the base url so http://localhost:5000 and http://<the-ip-address>:5000
cap5lut
cap5lut7mo ago
and do u see logs in the app console now?
ඞ Straßenfeger ඞ
yes i do
cap5lut
cap5lut7mo ago
and for the global ip?
ඞ Straßenfeger ඞ
i see something too
cap5lut
cap5lut7mo ago
the app logs?
ඞ Straßenfeger ඞ
well idm i show my ip now :skull_cry:
cap5lut
cap5lut7mo ago
do u use the same ip to ssh into the kvm from ur local machine?
ඞ Straßenfeger ඞ
yes
cap5lut
cap5lut7mo ago
then something with the firewall configuration of the kvm seems to be off, but there i dont have any experience
ඞ Straßenfeger ඞ
i did "sudo ufw allow 5000" that should allow the 5000 to be open i guess
cap5lut
cap5lut7mo ago
what does sudo ufw status | grep 5000 yield?
ඞ Straßenfeger ඞ
Nothing
cap5lut
cap5lut7mo ago
what does just sudo ufw status yield? seems like the firewall isnt correctly configured
ඞ Straßenfeger ඞ
i guess this is not good
cap5lut
cap5lut7mo ago
nope 😂
ඞ Straßenfeger ඞ
:skull_cry: but when i enable it everything will f up
cap5lut
cap5lut7mo ago
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 long
ඞ Straßenfeger ඞ
quite long is something else i guess :skull_cry:
cap5lut
cap5lut7mo ago
iptables --list?
cap5lut
cap5lut7mo ago
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
ඞ Straßenfeger ඞ
oh no this is bad
cap5lut
cap5lut7mo ago
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
ඞ Straßenfeger ඞ
oh no more work :pepe_Sad: but when the Firewall is inactiv then i would connect into the ASPNET
cap5lut
cap5lut7mo ago
thats indeed true 🤔
ඞ Straßenfeger ඞ
yes
cap5lut
cap5lut7mo ago
maybe just ask their support which firewall is in use because u cant access ur server at port 5000 but at the ssh port
ඞ Straßenfeger ඞ
it seems like that i don't have a external firewall
Want results from more Discord servers?
Add your server