I have a nodejs website hosted on vps hosting listening on port 8000. I did reverse proxy using nginx to listen all request on port 8000 to port 80 by changing the /etc/nginx/sites-available/default to following:
server {
listen 80;
server_name www.greenlemonevents.com;
location / {
proxy_pass http://67.209.122.170: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;
}
}
where 67.209.122.170 is my remote server ipadress. When i access my site by the ipaddress it is working fine but when i access it by the domain name apache2 pages is shown. http://www.greenlemonevents.com/ this is showing the apache2 default page and this http://www.greenlemonevents.com:8000/ is working fine. I do not understand why i have to add port when it is working fine here: http://67.209.122.170/ .
I have purged apache2 from the vps server and also removed /var/www/html folder but still it is showing the default ubuntu page.
This is my first time hosting on a vps hosting so pardon if i seem a bit confused... :)
Related
I am trying to deploy a nuxt blog to a virtual private server that runs nginx.
The blog is supposed to be accessible when I browse to https://exampledomain.com/articles
I have managed to run npm run dev on the server successifully... The app is running on localhost:3000 on the server....
I need to set a reverse proxy on the server to redirect all requests from https://exampledomain.com/articles/ to localhost:3000
I have tried this twice and its failing.... When I browse https://exampledomain.com:3000 the app is loading forever.... when I go to https://exampledomain.com/articles it says "Page not working", or "Internal server error"
Kindly assist
This could be happening due to incorrect configuration.
Try
sudo nano /etc/nginx/sites-available/your-domain.com
Remember to change the your-domain.com to your desire domain
server {
listen 80;
listen [::]:80;
index index.html;
server_name your-domain.com;
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;
}
}
I bought ubuntu server in digitalocean.
I am connecting my server IP through ssh on my terminal and i create a small node app and after starting the app, I can able to see my app running on my http://myipaddress:nodeport
How i can i connect my domain to this?
I bought free domain from freenom for testing purpose.
By following some tutorials i make a /etc/nginx/sites-available folder into my server and create a file called default and write code like this
server {
listen 80;
server_name sameer.tk; // i bought this domain from freenom
location / {
proxy_pass http://my_private_ip:3004 //with nodeport
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 if i hit sameer.tk after the setup its not working, i even restart my nginx.
You no need any nginx for node server.
You may run node server as 80 port and open 80 port in network security group.
After that, you should point domain to your instance public ip address in your domain management panel.
Ref:
https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars
I have a node.js backend application running on port 1337 and i want to deploy it to my nginx server so i can get access to my backend from another computer and other netwroks.
i tried this in sites_availables and i enabled this configuration :
server {
listen 80;
server_name x.x.x.x(my server adrress);
location /node {
proxy_pass http://localhost:1337;
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;
}
}
then i restarted nginx
sudo service nginx restart
now i'm trying to reach x.x.x.x/node through my browser and i get 501 bad getaway.
The reverse proxy pipe from nginx to node is being broken because your path in the nginx config /node does not exist on your node application. You either need to implement that route, or do a rewrite to have nginx rewrite the path when proxying (check out this question: https://serverfault.com/questions/586586/nginx-redirect-via-proxy-rewrite-and-preserve-url)
I am having troubles setting up NodeJs to work together with Nginx.
I have added forward of the subdomain to an IP address of my server. (when I ping subdomain it gives me the server IP address).
This is my config in /etc/nginx/sites-enabled/default
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name chat.mydomainname.com;
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;
}
}
My NodeJs server is running on port 3000 and I can access it via browser successfully on url http://MYIPADDRESS:3000
I noticed when I restart nginx server (service nginx restart) that I don't get any output that I usually should get.
I have tried to check what is on port 80 and does something blocks nginx from running. I killed those processes (which were all nginx) and I started it again, but no luck.
I am using Ubuntu 16.04 on Digital Ocean. (I have added subdomain on DigitalOcean also)
Can someone see some obvious mistake here?
Thanks!
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.