not to able to view the web application

Hi Experts,

       I am running webapplication in aws-ubuntu with nginx connecting uwsgi through sockets.

I connect to this machine through putty ssh. and the ipaddress I use is 54.253.108.37

When I run application,  I get bad gateway errors only for

http://54.253.108.37/iiif

but for http://54.253.108.37/  i get error_connection timeout.

Please see the logs when I run nginx

> ntdl@1.0.2 start-prod /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl
> concurrently --no-color "uwsgi --emperor code/uwsgi.ini --uid www-data  --gid www-data" "nginx"  "npm run render-prod"

[0] *** Starting uWSGI 2.0.15 (64bit) on [Wed Feb 21 03:31:48 2018] ***
[0] compiled with version: 5.4.0 20160609 on 09 February 2018 02:01:25
[0] os: Linux-4.4.0-1049-aws #58-Ubuntu SMP Fri Jan 12 23:17:09 UTC 2018
[0] nodename: ip-10-244-152-179
[0] machine: x86_64
[0] clock source: unix
[0] pcre jit disabled
[0] detected number of CPU cores: 8
[0] current working directory: /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl
[0] detected binary path: /usr/local/bin/uwsgi
[0] setgid() to 33
[0] setuid() to 33
[0] *** WARNING: you are running uWSGI without its master process manager ***
[0] your processes number limit is 60090
[0] your memory page size is 4096 bytes
[0] detected max file descriptor number: 1048576
[0] *** starting uWSGI Emperor ***
[1] nginx exited with code 0
[2]
[2] > ntdl@1.0.2 render-prod /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl
[2] > babel-node node/react-render.jsx
[2]
[0] *** has_emperor mode detected (fd: 5) ***
[0] [uWSGI] getting INI configuration from code/uwsgi.ini
[0] *** Starting uWSGI 2.0.15 (64bit) on [Wed Feb 21 03:31:49 2018] ***
[0] compiled with version: 5.4.0 20160609 on 09 February 2018 02:01:25
[0] os: Linux-4.4.0-1049-aws #58-Ubuntu SMP Fri Jan 12 23:17:09 UTC 2018
[0] nodename: ip-10-244-152-179

[0] machine: x86_64
[0] clock source: unix
[0] pcre jit disabled
[0] detected number of CPU cores: 8
[0] current working directory: /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl
[0] detected binary path: /usr/local/bin/uwsgi
[0] chdir() to /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/
[0] your processes number limit is 60090
[0] your memory page size is 4096 bytes
[0] detected max file descriptor number: 1048576
[0] lock engine: pthread robust mutexes
[0] thunder lock: disabled (you can enable it with --thunder-lock)
[0] uwsgi socket 0 bound to UNIX address /tmp/ntdl.sock fd 3
[0] Python version: 3.5.2 (default, Nov 23 2017, 16:37:01)  [GCC 5.4.0 20160609]
[0] Python main interpreter initialized at 0x16faf80
[0] python threads support enabled
[0] your server socket listen backlog is limited to 100 connections
[0] your mercy for graceful operations on workers is 60 seconds
[0] mapped 537088 bytes (524 KB) for 20 cores
[0] *** Operational MODE: threaded ***
[0] WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x16faf80 pid: 6889 (default app)
[0] *** uWSGI is running in multiple interpreter mode ***
[0] spawned uWSGI master process (pid: 6889)
[0] Wed Feb 21 03:22:58 2018 - [emperor] vassal code/uwsgi.ini has been spawned
[0] spawned uWSGI worker 1 (pid: 6922, cores: 20)
[0] Wed Feb 21 03:22:58 2018 - [emperor] vassal code/uwsgi.ini is ready to accept requests
[2] React render server listening at http://0.0.0.0:9009
[0] [pid: 7583|app: 0|req: 1/1] 120.150.29.97 () {40 vars in 693 bytes} [Wed Feb 21 13:19:01 2018] GET /favicon.ico => generated 0 bytes in 2 msecs (HTTP/1.1 301) 4 headers in 185 bytes (1 switches on core 0)
[0] announcing my loyalty to the Emperor...
[0] Wed Feb 21 03:49:01 2018 - [emperor] vassal code/uwsgi.ini is now loyal
[0] [pid: 7583|app: 0|req: 2/2] 120.150.29.97 () {40 vars in 717 bytes} [Wed Feb 21 13:19:10 2018] GET /cms => generated 0 bytes in 1 msecs (HTTP/1.1 301) 4 headers in 177 bytes (1 switches on core 2)

Nginx.conf settings has the following data

user www-data;

events {
        worker_connections 768;
        # multi_accept on;
}

http {
     #upstream django {
        #server unix://tmp/ntdl.sock;
        #server unix://home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/ntdl.sock;
        #server 127.0.0.1:8000;
     #}

     ssl_session_cache    shared:SSL:10m;
     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;
     keepalive_timeout 65;
     types_hash_max_size 2048;
     include /etc/nginx/mime.types;
     default_type application/octet-stream;
     ssl_certificate_key your-cert.key;
     ssl_session_timeout 5m;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
     ssl_prefer_server_ciphers on;

     #upstream uwsgi_frontend {
     #  server 127.0.0.1:8000;
     #}

     server {
         listen      80 default;
         listen [::]:80 ipv6only=on;
         listen      443;
         listen [::]:443 ipv6only=on;
         #server 127.0.0.1;
         #server_name 54.253.108.37;
         charset     utf-8;
         client_max_body_size 50M;

         location /media  {
             alias /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/media;
         }

         location /static {
             alias /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/static;
         }

         access_log /var/log/nginx/access.log;
         error_log /var/log/nginx/error.log;

         location / {
            #uwsgi_pass django;
            #uwsgi_pass 127.0.0.1:8000;
            uwsgi_pass unix:///tmp/ntdl.sock;
            include /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/uwsgi_params;
            root     /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/static;
            #proxy_redirect     off;
            #proxy_pass         http://127.0.0.1:80/;
            #proxy_set_header   Host $http_host;
            #proxy_set_header   X-Real-IP $remote_addr;
            #proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            #proxy_set_header   X-Forwarded-Host "54.253.108.37";
         }

         #location / {
         #      proxy_pass          http://127.0.0.1:8008;
         #}

         location /trove {
                uwsgi_param     SCRIPT_NAME /project;
                uwsgi_param PATH_INFO "$1";
                rewrite /trove/(.*) /$1 break;
                proxy_pass          http://127.0.0.1:8010;
         }

         location /iiif {
            proxy_redirect     off;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host "54.253.108.37/iiif";
            rewrite /iiif/(.*) /$1 break;
            proxy_pass          http://127.0.0.1:8009;
         }
      }
}

please see below the uwsgni.ini configuration
[uwsgi]
chdir=/home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/
module=ntdl.wsgi:application
master=True
vacuum=True
max-requests=5000
socket = /tmp/ntdl.sock
#chmod-socket = 664
#http-socket = 127.0.0.1:8000
chmod-socket = 777
#uid = www-data
uid = www-data
gid = www-data
enable-threads = true
threads = 20


with root having the following value
root     /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/static;

without root or root commented
#root   /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/code/static;

for both the scenerio's I get the following the error.
for http://54.253.108.37/  the site can't be reached 54.253.108.37 look tool long to respond Err_connection_timeout

I get bad gateway error
for http://54.253.108.37/iiif

the logs for nginx /var/log/nginx/error.log has following details.

2018/02/21 04:06:05 7965#7965: *2 connect() failed (111: Connection refused) while connecting to upstream,
client: 120.150.29.97, server: , request: "GET /iiif HTTP/1.1", upstream: "http://127.0.0.1:8009/iiif", host: "54.253.108.37"


2018/02/21 04:10:22 8075#8075: *6 connect() failed (111: Connection refused) while connecting to upstream,
client: 120.150.29.97, server: , request: "GET /iiif HTTP/1.1", upstream: "http://127.0.0.1:8009/iiif", host: "54.253.108.37"
2018/02/21 04:10:33 8075#8075: *6 connect() failed (111: Connection refused) while connecting to upstream,
client: 120.150.29.97, server: , request: "GET /iiif HTTP/1.1", upstream: "http://127.0.0.1:8009/iiif", host: "54.253.108.37"
2018/02/21 04:10:54 8075#8075: *6 connect() failed (111: Connection refused) while connecting to upstream,
client: 120.150.29.97, server: , request: "GET /iiif HTTP/1.1", upstream: "http://127.0.0.1:8009/iiif", host: "54.253.108.37"


Please help me in fixing this issue

TIA,

With many thanks,
Bharath AK
LVL 1
Bharath A.KAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

systechadminConsultantCommented:
have you created the endpoints?  I mean you need to open the ports on aws machine
0
Bharath A.KAuthor Commented:
Hi Gaurav,

Yes the ports are open.  the log says react render server is listening on 9009 do I have open this port?  The ports 80, 443(https), postgresql port 5432 and ssh ports are open in aws.  

 Will there be any difference when I run uwsgi in emperor mode or normal mode?

secondly bad gateway error when I try http://54.253.108.37/iiif  how to fix this error.

How can I configure many applications on nginx?

Please through light on how to configure many applications with nginx along with uwsgi which can connect each other through http or sockets and also how to use nginx as proxy?

With Many Thanks,
Bharath AK
0
Bharath A.KAuthor Commented:
Hi Gaurav,

What are endpoints?

With Many Thanks,

Bharath AK
0
Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

Bharath A.KAuthor Commented:
Hi Gaurav,

       What is the difference in providing and not providing the root path?  by default in server configuration in nginx.conf is listen 80 default;

some time we provide server 127.0.0.1:80 or localhost  can we provide some other ip address at this place.   Please explain how to  configure of  the proxy settings

proxy_redirect     off;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host "54.253.108.37/iiif";
            rewrite /iiif/(.*) /$1 break;
            proxy_pass          http://127.0.0.1:8009;

is there any thing wrong in the above configuration.

With Many thanks,
Bharath AK
0
systechadminConsultantCommented:
yes you can provide the Public IP over there and see if that works ..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bharath A.KAuthor Commented:
Hi Gaurav,

         It is working now.  I don't understand how it works.  I think I should have complete understanding of nginx configuring upstream server and proxy server and about general nginx configuration.

Thanks,

Bharath AK
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DevOps

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.