Welcome! Log In Create A New Profile

Advanced

nginx with nodejs and elastic search

Posted by jiteshanand 
nginx with nodejs and elastic search
May 14, 2016 01:54PM
I am using nginx as web/proxy server for my website build using MEAN stack. So the configuration file for nginx looks like
server {
listen 80;
server_name www.domainname.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;
}

location /blog {
proxy_pass http://localhost:2368;
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;
}
}


Node server is running on port 3000 and my blog is running on 2368.This setup is running fine.
Now I have included elasticsearch also in the same aws server which is listening to port 9200.I want to make changes in nginx config.

Can someone please help me with the change to include elasticsearch also.I had already tried to include below code but it is not working

server {
listen 9200;
server_name www.domainname.com;
location / {
rewrite ^/(.*) /$1 break;
proxy_ignore_client_abort on;
proxy_pass http://localhost:9200;
proxy_redirect http://localhost:9200 http://www.domainname.com:9200/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

}
}

After adding this code nginx service is not coming up.
Re: nginx with nodejs and elastic search
May 14, 2016 04:55PM
jiteshanand Wrote:
-------------------------------------------------------
> listen 9200;
.......
> proxy_pass http://localhost:9200;

Your listening and passing on the same port.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 112
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready