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 and added the following code in nginx config file
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 ..I am getting error
bind() to 0.0.0.0:9200 failed (98: Address already in use)
Can anyone help me in this.Thanks