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
ඞ Rainbow Snowy Nuggi ඞ
Sorry for the German
cap5lut
cap5lut8mo ago
the ASP.NET project listening for localhost, so only IP addresses like 127.0.0.1 and ::1 or other configured loopback addresses.
ඞ Rainbow Snowy Nuggi ඞ
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
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
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
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
i want to run it as standalone
cap5lut
cap5lut8mo ago
sec, been eternities since i ran such stuff standalone, so i need to find how to configure it quickly
cap5lut
cap5lut8mo 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.
ඞ Rainbow Snowy Nuggi ඞ
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
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
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
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
it's still not working same error
cap5lut
cap5lut8mo ago
on that linux machine, can u reach the app via that IP and localhost?
ඞ Rainbow Snowy Nuggi ඞ
i onyl have Linux on Console not on Remote Based or wait you mean if i should ping it?
ඞ Rainbow Snowy Nuggi ඞ
Seems like not
cap5lut
cap5lut8mo ago
what do u mean by "linux on console"?
ඞ Rainbow Snowy Nuggi ඞ
like via SSH Sorry
cap5lut
cap5lut8mo ago
is that a completely remote machine or is it in ur local network, just a different computer?
ඞ Rainbow Snowy Nuggi ඞ
it's a compleatly remote mashine from https://deinserverhost.de/ a KVM
cap5lut
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
what do you mean by that? Like place a random file and then i do wget ip:5000/Home/Secret something like that
cap5lut
cap5lut8mo ago
just the base url so http://localhost:5000 and http://<the-ip-address>:5000
cap5lut
cap5lut8mo ago
and do u see logs in the app console now?
ඞ Rainbow Snowy Nuggi ඞ
yes i do
cap5lut
cap5lut8mo ago
and for the global ip?
ඞ Rainbow Snowy Nuggi ඞ
i see something too
cap5lut
cap5lut8mo ago
the app logs?
ඞ Rainbow Snowy Nuggi ඞ
well idm i show my ip now :skull_cry:
cap5lut
cap5lut8mo ago
do u use the same ip to ssh into the kvm from ur local machine?
cap5lut
cap5lut8mo ago
then something with the firewall configuration of the kvm seems to be off, but there i dont have any experience
ඞ Rainbow Snowy Nuggi ඞ
i did "sudo ufw allow 5000" that should allow the 5000 to be open i guess
cap5lut
cap5lut8mo ago
what does sudo ufw status | grep 5000 yield?
ඞ Rainbow Snowy Nuggi ඞ
Nothing
cap5lut
cap5lut8mo ago
what does just sudo ufw status yield? seems like the firewall isnt correctly configured
ඞ Rainbow Snowy Nuggi ඞ
i guess this is not good
cap5lut
cap5lut8mo ago
nope 😂
ඞ Rainbow Snowy Nuggi ඞ
:skull_cry: but when i enable it everything will f up
cap5lut
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
quite long is something else i guess :skull_cry:
cap5lut
cap5lut8mo ago
iptables --list?
cap5lut
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
oh no this is bad
cap5lut
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
oh no more work :pepe_Sad: but when the Firewall is inactiv then i would connect into the ASPNET
cap5lut
cap5lut8mo ago
thats indeed true 🤔
cap5lut
cap5lut8mo 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
ඞ Rainbow Snowy Nuggi ඞ
it seems like that i don't have a external firewall
Want results from more Discord servers?
Add your server