I'm working on localhost and Windows OS. NGINX run on port 80 and Node.js app(Ghost) run on port 2368.
I want to use NGINX as front web server for Ghost app. So in nginx.conf file I wrote:
server {
listen 80;
server_name localghost;
# change above to example.com in production mode
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}
NGINX directory is C:\nginx, Ghost directory is C:\nginx\www\ghost.
http://localghost address is not opening Ghost app. How can i do that?
Does localghost resolve to anything?
If you are testing on your development machine, then I would suggest to just use localhost and be done with it.
Related
When I setup simple nginx location to catch all traffic to root and proxy-pass to nodeJS on port 3000, when I request http://example.com/something
When I enter mydomain.net I got result from nodeJS, but when I tried example.com/something, I'm getting 502 Bad Gateway.
server {
listen xxx.xxx.xxx.xxx:80;
server_name example.com www.example.com;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:3000/;
}
}
I expect nodeJS to handle rest of url (after /) as this working without nginx, when nodeJS is alone on port 80.
aste the following code in the file and make sure to change example.com to your domain (or IP), and 1337 to your Node.js application port:
server {
listen 80;
server_name example.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass "http://127.0.0.1:3000";
}
}
than
sudo nginx -t
sudo service nginx restart
I figure out that nginx code was ok, my SSL configuration seems to make problem here and after checked error log of nginx, started again and get successfully all locations to NodeJS. Thanks all.
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... :)
I have a Digitalocean VPS and 3 Nodejs (ExpressJs) application. Now I started all of them in same IP and different port like this:
- 95.5.5.8:65001
- 95.5.5.8:65002
- 95.5.5.8:65003
But now I want when anybody writes app1.com, the first app 95.5.5.8:65000 shows to him like this:
app1.com -> load server in port 65001
app2.com -> load server in port 65002
app3.com -> load server in port 65003
All of the applications are in same VPS by the same IP, How can I do this, please?
You can implement this feature by following steps:
In domain setting page, map app1.com, app2.com and app3.com to 95.5.5.8.
In Nginx, configure 3 proxies for app1.com, app2.com and app3.com in directory /etc/nginx/conf.d/. Here is the proxy file /etc/nginx/conf.d/app1.conf for app1.com:
server {
listen 80;
server_name app1.com;
access_log /var/log/nginx/app1_access.log;
charset utf-8;
location / {
proxy_pass http://95.5.5.8:65001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
}
}
Restart Nginx.
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 running a Ripple-Rest server on a CrunchBang Linux (Debian) computer. It runs on the port 5990. I ran the server on this computer and it works fine when i view it via localhost but after port forwarding 5990 on my router I cannot acces this server from any other computer via public IP. I have given full permissions to all of the files the server uses as well.
Below are links to screen shots of what I have done:
https://dl.dropboxusercontent.com/u/108273736/capture.png
Please let me know what I can do to get this to work!
I found the best way to do this is proxy it through nginx. That way you can use standard port for accessing the service and leave the ripple-rest service as local.
apt-get install nginx
change /etc/nginx/sites_enabled/default
... add in the following..
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name yourservername.com;
location / {
proxy_pass http://localhost:5990;
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 seems that port 5990 is blocked either from your isp or iptables. You could check on remote if connections to 5990 are allowed by iptables if it is running thst is.
If you would like to run a listener on 80 that forwsrds to 5990 on remote or you could run local port forwarding.
http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
Assuming ssh on 22 is almost always open.
We faced a similar issue on amazon ec2 and our data center:
http://khanna111.com/wordPressBlog/2013/01/05/amazon-web-service-aws-and-vnc/