nginx Ubuntu nodeJs - Server only handles requests from local network - node.js

I followed all kinds of instructions all day to get my first server up and running. I tested it on 3 devices and thought I had it... until my friend tried it and discovered "site can't be reached."
In double-checking on my end, I found that if I disconnected my phone from wi-fi, sure enough, I couldn't reach my server.
I realize there could be a million things wrong, but I don't know where to start. I am not even sure what additional information I should include to help find the issue. If I had to guess, I'd say I failed to open the firewall on my server port 80. But I really have no clue. Ubuntu is new to me.

Can you include details about your setup? How is the Ubuntu server configured? If it's your own hardware, have you forwarded the ports on your router? Do you have a Dynamic DNS server in place? Is there an internal firewall (ufw?). Is the Node.js server bound to the loopback? Is Nginx in proxy_pass mode?
As mentioned by the OP, the ports weren't forwarded.

Related

Can connect to nginx server inside LAN but not publicly

I'm trying to set up a Mastodon instance on my Raspberry Pi 4 at home, running Raspbian/Debian Linux. I have no idea what I'm doing.
The nginx server is running, working. When I access it from localhost or from inside the LAN, it gives a result like this, as expected:
When I try to access it from outside the LAN, it eventually times out or gives a "connection was reset" error.
Or in firefox:
At first I suspected that it was a problem with my firewall, like maybe it was blocking HTTP traffic into it. But it's allowing HTTP traffic through. I even stopped the firewall entirely, but it's still doing the same thing. (I'm using IPTables)
All of the necessary ports should be forwarded to the pi on my optimum router:
Here's the site's nginx config, just an edited copy of mastodon's given nginx configuration template. I have the HTTPS server commented out, as I'm only working with HTTP right now. I'm trying to get the http server working so I can use certbot to get an SSL certificate, but certbot's unable to connect to the nginx server, runs into the same "connection reset" error. The server_name is irrelevant (or is it?) as i'm just trying to connect to it through IP right now, and commented out the other "location" properties that the template came with, as I'm just trying to get the server to work in the first place, running mastodon on it and getting the SSL certificate and getting the domain to work will come after.
What causes it to work inside LAN but not outside it? Even with the necessary ports forwarded to the pi?
Edit:
Here's what it looks like inside the LAN, working correctly:
and here's when I try to access it outside the LAN (through ProtonVPN in this case)
https://www.reddit.com/r/OPTIMUM/comments/rxjw1v/optimum_internet_not_forwarding_traffic_on_port_80/
By default, Optimum blocks ports 80 and 25, even if they are port-forwarded.
Optimum support referred me to this obscure page that I couldn't find linked anywhere on the site, did exactly what i needed: https://www.optimum.net/internet/boost/

Port accessible only using wget localhost

I have a server running centos 7 using cpanel and whm with csf. I am trying to run a nodejs express application on it that listens on port 3000. In order to do so, I added the line tcp|in|d=3000|s=0.0.0.0 to csf.allow.
When I run the code and use wget localhost:3000, I get the html files as expected, but if I try to connect from a browser the server just doesn't get the request. Am I doingsomehting wrong?
I am new to Linux and server management, so sorry in advance if I didn't give enough information. I'll be happy to provide more if needed.
If anyone stumbles upon this from Google, the problem was that my server provider was blocking uncommon ports. I mailed them and after two minutes the problem was solved.

How to access local web server from another computer

I know this may be asked in different threads, but I really couldn't find a solutions for my simple problem.
I have a web server (Ubuntu) on port 4000 running and I want to access it from my second computer (same network). I don't mind if it's exposed to the Internet (it's only temporally).
I can ping the web server computer, but port 4000 is not reachable.
Can some give me a simple solution for this problem? That would make my day.
EDIT:
I run jekyll serve
EDIT:
Okay I found a really helpful blog entry for solving my problem.
link
If you are running Apache2 webserver edit your configuration like this:
From:
Listen 127.0.0.1:4000
To:
Listen 4000
See https://httpd.apache.org/docs/current/en/bind.html for reference.
Configuration examples for nginx are available here: https://nginx.org/en/docs/http/ngx_http_core_module.html#listen
Restart/reload your apache2 or nginx service to apply configuration changes.
Your webserver is now reachable through http://[webserverip]:4000

Amazon Nodejs webserver

I'm getting stuck here, so i have an amazon ec2 (standard redhat server) host up and working. i can connect to it personally no problem, however it cannot be connected to outside of my ip.
I've checked the rules and i have port 80 and 3000 open to 0.0.0.0/0 to be able to communicate, however outside of my computer (and computers in this network) i can not connect.
Everything I've found is about connecting to ssh which works fine, i have no rules in iptables, i haven't dealt much with them before, but since i can connect to the service i don't think its the issue.
summary:
Web server is running, i can connect from my computer to it, and any others in my local network, but nothing outside of it works.
i do have httpd installed as well as a simple forward from the browser to port 3000, however i cant connect to it either from outside my network.
so this is a new one for me, the dns forwarding works in houst, but not outside. so inside and outside here, i can use IP address to connect, but inside only i can connect with my dns lookup. not sure what caused this, but its not an amazon problem at least. going to look at that side.

cant hit ghost blog on remote server (Failed to load resource: net::ERR_CONNECTION_REFUSED)

I've installed ghost as per the instructions on the official documentation: http://support.ghost.org/installing-ghost-linux/
When I run ghost in development or prod mode, I get this output:
Ghost is running in development...
Listening on 127.0.0.1:2368
Url configured as: http://localhost:2368
Which is exactly what I expect. Now my remote server has an ip of something, lets say 123.456.68.1. I should be able to hit the running ghost server by going to http://123.456.68.1:2368 right? Well when I try doing that I get this error:
Failed to load resource: net::ERR_CONNECTION_REFUSED
What am I doing wrong? Please help!
NOTE
If I run a node server on port 80 I can hit it by going to 123.456.68.1. For somereason I cant hit the ghost server.
Without some more details on where your server is ect this is a bit hard to answer.
First check to ensure that your server socket is bound to the correct interface. The fact that it is saying it is on 127.0.0.1 may mean that it is bound to the loopback interface and this means that you can't connect to it from another machine. Run the following to check:sudo netstat -ntlp. If this shows your process bound to 127.0.0.1 then this is likely the problem. You can fix it by passing 0.0.0.0 in the listen call: connect().use(connect.static('public')).listen(3000, "0.0.0.0");
If that isn't the problem then it is likely that you network setup is the problem. There are many places here it could be. Firewalls, routers, port forwarding configurations ect. If the above doesn't work then we will need to know a little bit more about your setup to help further.

Resources