I have started node service in the port 3000 and i opened the port 3000 in the server, however i can't connect the web app. Anyone can help me, thank you!
Here is the screenshot of my port status.
When i use
nmap -p 3000 202.117.43.155
It shows
So the port 3000 is showed as status "filtered", where is the block?
in your node app check if you are using app.listen(PORT, IP_ADDRESS_OR_HOST )
try to use app.listen(PORT) instead`
I solved this problem by applying Nginx.
After install Nginx,
sudo nano /etc/nginx/sites-available/example.com
server {
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}```
Related
I recently started tinkering to solve this problem I was having this problem. So I installed NGINX and set it up so that it forwards the incoming requests on port 80 to port 300 by creating a .conf file in /etc/nginx/conf.d/ location. Here is the configuration file.
server {
listen 80;
server_name xyz.xyz;
location / {
proxy_pass http://127.0.0.1:300;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
But when I hit xyz.xyz I get the default page and when I go to xyz.xyz:300 I get my NodeJS app. Any suggestion?
Seems like it was an issue with SELinux.
I just ran this command and it worked.
setsebool -P httpd_can_network_connect 1
I am having issues redirecting my port 80 to 4000 where my nodejs application is running on my Digital Ocean Ubuntu Droplet. Here is my /etc/nginx/sites-available/default file:
server {
listen 80;
server_name my_site.com;
location / {
proxy_pass http://MY_IP_ADDRESS:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
When ever I head over to my droplet's IP on port 4000 the application loads successfully but not when I try on port 80.
You are doing a proxy_pass of port :8080 but you said your application is running on port 4000.
You need to tell nginx the correct port to proxy, (4000 instead of 8080)
Then you need to restart the nginx service sudo service nginx restart
I have 2 node js app deploy to Digital Ocean (Ubuntu 16.04), I use pm2 for application management. I try to use nginx as a web server but now I want to run 2 app with different port for example:
App 1: http://my_ip:3001
App 2: http://my_ip:3002
I try to config nginx but it seem not work:
server {
listen 3001;
location / {
proxy_pass http://localhost:8080; //Node app
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
It work only on port 80.
What configuration I need to do for this problem? Thanks
UPDATE: Just using ufw to open the ports
I have a server with two two Single Page Application (using a framework) running using node http-server:
website1 running on port 80: IP_ADDRESS:80
website2 running on port 8080: IP_ADDRESS:8080
Currently the workflow is using this two commands to deploy the two sites
pm2 start /usr/bin/http-server -f --name website1 -- -p 80 -d false
pm2 start /usr/bin/http-server -f --name website2 -- -p 8080 -d false
At the end, our sites run on domain like this:
subdomain.mysite.com for website1
subdomain.mysite.com:8080 for website2.
This is not desired, we wanted like this:
subdomain.mysite.com for website1
subdomain2.mysite.com for website2
I tried to install nginx, with the follow reverse proxy configurations:
server {
listen 80;
server_name subdomain2.mysite.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Hoping that now, if I type subdomain2.mysite.com, it will bring me to the website2 on port 8080, but it didn't, it brings me to website1 on port 80 instead. In fact, I cant be sure if this reverse proxy is working at all.
I am sure I configured something wrongly, what could be the problem?
p/s: I also wonder if I am doing it entirely wrong - if I am using nginx for reverse proxy, should I stop using http-server directly?
Node and Nginx can't both listen on port 80 at the same time. If you want to reverse proxy both you'll need to use a different port for the first Node app and add another virtual host to your nginx file for it.
For example, changing the first app's port to 8000 would look like:
pm2 start /usr/bin/http-server -f --name website1 -- -p 8000 -d false
pm2 start /usr/bin/http-server -f --name website2 -- -p 8080 -d false
With the following Nginx configuration:
server {
listen 80;
server_name subdomain2.mysite.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name subdomain1.mysite.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
You probably also want to add the proxy_redirect off; flag to each block.
I am using a DigitalOcean VPS hosting a meteor app. I don't have a domain name yet, so just use the plain IP address. When I set below config and use myipaddress:3000 and myipaddress:8080, both of them worked well; but if I change the 8080 to 80, only myipaddress:3000 works. Using only myipaddress or myipaddress:80 will show "Welcome to nginx on Debian!" message. (I use Ubuntu 14.04 on the VPS).
server {
listen 8080;
server_name default;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Can not figure out why can't use port 80.
---- Solved this problem --------
I commented out the "listen 80 default_server" in the /etc/nginx/sites-enabled/default" file, then my config at "/etc/nginx/conf.d/mysite.conf" works on port 80.
You probably still have the default.conf still in the directory that nginx is using to serve up the sites. either that or check in nginx.conf. Somewhere there is a server setup already using 80 that is being served first.