Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

nginx with nodejs and elastic search

$
0
0
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.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>