skip to Main Content

Only localhost can access server_ip:port_no, but other devices can’t. It always show not secure with blank page and static files I place in nginx are not showing either. When I inspecting the browser, it shows

:8443/favicon.ico:1 
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR

I checked TCP connection with netstat -an | findstr :8443 just to ensure and it shows list of my server_ip and other devices listening correctly. I also manually enable inbound firewall rules with port 8443. Didn’t work. I just want other devices to access my webapp on the same internal network.

This is my nginx.conf with only http protocol.

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 8443;
        server_name 192.168.xxx.xx;

        root html;
        index index.html index.htm;

        location / {
            try_files $uri $uri/ /index.html;
        }

        location /api/ {
            proxy_pass http://localhost:8050;
            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 /static/ {
            try_files $uri =404;
        }

        location ~* .(js)$ {
            try_files $uri =404;
        }

        location ~* .(css)$ {
            try_files $uri =404;
        }

        location ~* .(png|jpg|jpeg|gif|ico|svg)$ {
            try_files $uri =404;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}



2

Answers


  1. Chosen as BEST ANSWER

    Already fixed the issue. This has nothing to do with the nginx. Actually, the default nginx.conf works fine. The solution was to remove this browser policy <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> in react index.html.


  2. If the Host header field does not match a server name, NGINX Plus routes the request to the default server for the port on which the request arrived. The default server is the first one listed in the nginx.conf file, unless you include the default_server parameter to the listen directive to explicitly designate a server as the default.

    https://docs.nginx.com/nginx/admin-guide/web-server/web-server/

    The issue is this server_name 192.168.xxx.xx;

    If you are calling the server via an IP different from "192.168.xxx.xx" such as "192.168.yyy.yy" then it will not call that server directive.

    NGINX will only use this server directive if the IP/domain matches. In this case the IP.

    Try changing to listen 8443 default_server;

    Otherwise, if you are calling with that same server IP for certain, then show the HTTPS server config as well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search