无法访问本地网络android中的Nginx服务器

时间:2018-09-09 13:40:16

标签: android nginx

我的问题是我的手机无法访问使用nginx的本地网络中的服务器

我可以直接从我的机器上访问它,也可以从genymotion模拟器中访问它: enter image description here

但是我的Android手机(7.1.2 N2G47H; Redmi Note 5A Build)无法加载。它一直处于加载状态,直到浏览器(Chrome 68.9.3440.91)认为响应时间已超过。

我试图通过本地网络(192.168.1.123)上的计算机IP访问服务器

但是,如果我使用python中的SimpleHTTPServer模块提供文件,则可以正常工作,可以提供文件。

nginx.conf:

user tauyekel staff;
worker_processes auto;

events {
    worker_connections  1024;
}

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

    sendfile on;
    keepalive_timeout  65;
    client_max_body_size 128M;

    gzip  on;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;

    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;

    server {
        listen *:80;

        # serve static files
        location ~ ^/.*$ {
            root /Users/tauyekel/Documents/webprojects/mobile-test;
        }
    }
}

我的包含静态文件的目录由单个index.html组成:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Mobile Test</title>
</head>
<body>
    <h2>Tauka!</h2>
</body>
</html>

iOS设备也没有运气

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我不确定我是否正确理解了您的问题,但是我想知道您的手机如何连接到网络?您的计算机通过以太网电缆或wi-fi连接到它。这样就为它分配了网络内的IP地址,并且可以解析连接。您的手机也使用Wi-Fi吗?还是只是打开浏览器窗口并输入IP地址?如果没有Wi-Fi连接到本地网络,电话将使用手机提供商的网络连接来访问Internet。问题是您的计算机IP地址192.168.1.123是一个专用网络地址,无法从Internet上访问。