Lightsails instance works by curl test, but not on browser

0

Hello, I have spent a lot of time to find solution for my problem, but didn't work, I hope I could get some help here. Bellow is a short description of my present condition:

error
chrome: ERR_CONNECTION_TIMED_OUT

I deployed my django App in my new Lightsails instance, everything seems to be OK in the backend.
however, I can not access my site through browser

nginx:

\[centos@myip ~]$ ps aux|grep nginx  
root     28250  0.0  0.0  39300   992 ?        Ss   10:33   0:00 nginx: master process /usr/sbin/nginx  
centos   28251  0.0  0.0  39756  2112 ?        S    10:33   0:00 nginx: worker process  
centos   28252  0.0  0.0  39756  1876 ?        S    10:33   0:00 nginx: worker process  
centos   30531  0.0  0.0 112812   976 pts/0    R+   10:37   0:00 grep --color=auto nginx  

nginx configuration

user centos;  
worker_processes auto;  
error_log /var/log/nginx/error.log;  
pid /run/nginx.pid;  
  
# Load dynamic modules. See /usr/share/nginx/README.dynamic.  
include /usr/share/nginx/modules/*.conf;  
  
events {  
    worker_connections 1024;  
}  
  
http {  
    log_format  main  '$remote_addr - $remote_user \[$time_local] "$request" '  
                      '$status $body_bytes_sent "$http_referer" '  
                      '"$http_user_agent" "$http_x_forwarded_for"';  
  
    access_log  /var/log/nginx/access.log  main;  
  
    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;  
  
    include /etc/nginx/conf.d/*.conf;  
    include /etc/nginx/sites-enabled/*;  
    upstream uwsgi_backend {    
        server 127.0.0.1:8888;  
    }  
  
    upstream channels-backend {    
        server localhost:8000;  
    }  
  
    server {  
        listen       80 default_server;   
        listen       \[::]:80 default_server;  
        server_name   _;  
        root         /usr/share/nginx/html;  
  
        # Load configuration files for the default server block.  
        include /etc/nginx/default.d/*.conf;  
  
        location / {  
            proxy_http_version 1.1;  
            proxy_set_header Host $host;  
            proxy_set_header X-Real-IP $remote_addr;  
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
            proxy_read_timeout 3600;  
            include uwsgi_params;  
            uwsgi_pass  uwsgi_backend;  
        }  
  
        location /static/ {  
            root  /home/path/to/app;    
        }  
  
        location /media/ {  
            root   /home/path/to/app;    
        }  
  
        location /ws/ {  
            proxy_pass http://channels-backend;  
  
            proxy_http_version 1.1;  
            proxy_set_header Upgrade $http_upgrade;  
            proxy_set_header Connection "upgrade";  
            proxy_redirect off;  
            proxy_set_header Host $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 $server_name;  
        }  
  
        error_page 404 /404.html;  
            location = /40x.html {  
        }  
  
        error_page 500 502 503 504 /50x.html;  
            location = /50x.html {  
        }  
    }  
}  
  
  
**ports opened on my server:**  

[centos@myip ~]$ netstat -lnt |grep 8
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp6 0 0 :::80 :::* LISTEN

  
**curl from remote Windows computer:**  

C:\Users\admin>curl http://xx.xxx.xxx.xx:80

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>stdworkflow</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="explore technologies, sharing knowledge about programming, data analyzing, AI, scientific research tools and methods and so on "> <meta name="author" content="__heihei__"> ...etc ``` lightsail: <http://35.175.206.18>

please help

Edited by: geoer on Jul 21, 2021 4:14 AM

geoer
asked 3 years ago209 views
3 Answers
0

Works for me.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>stdworkflow</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="explore technologies, sharing knowledge about programming, data analyzing, AI, scientific research tools and methods and so on "> <meta name="author" content="__geoer__">
profile picture
David G
answered 3 years ago
0

I have solved my problem, it is because I have resolved a domain name to my instance, so I could only access through the domain but not ip address (don't know why).

on the other hand, I meet a new problem: static files can not be loaded, nginx was rejected when accessing static resources (403 Forbidden), solved by following: https://stdworkflow.com/365/403-forbidden-when-nginx-accesses-static-resource-files-css-js-images

Edited by: geoer on Jul 21, 2021 8:54 AM

geoer
answered 3 years ago
0

solved

geoer
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions