Ngrok未正确掘进Nginx

Ngrok未正确掘进Nginx,nginx,ip,ngrok,tunnel,Nginx,Ip,Ngrok,Tunnel,我将我的flask应用程序部署在我的虚拟机上的Nginx上 一切都部署好了,我可以在上面请求API(我有一个公共IP) 但是当我运行Ngrok(我需要https,而且我没有域名来生成SSL证书)时,URL https//number.Ngrok.io会显示Nginx主页(欢迎使用Nginx),而不是我的webapp 为什么会这样 注意:当我运行“curl-localhost”时,我会看到Nginx欢迎页面,但当我执行“curl-4localhost”时,我会看到我的webapp主页 etc/ng

我将我的flask应用程序部署在我的虚拟机上的Nginx上

一切都部署好了,我可以在上面请求API(我有一个公共IP)

但是当我运行Ngrok(我需要https,而且我没有域名来生成SSL证书)时,URL https//number.Ngrok.io会显示Nginx主页(欢迎使用Nginx),而不是我的webapp

为什么会这样

注意:当我运行“curl-localhost”时,我会看到Nginx欢迎页面,但当我执行“curl-4localhost”时,我会看到我的webapp主页

etc/nginx/site available/myproject

server {
    listen 80;
    server_name 0.0.0.0;
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}

server {
    listen 80;
    server_name 127.0.0.1;

    location / {
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}

server {
    listen 80;
    server_name localhost;

    location / {
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}

server {
    listen 80;
    server_name public.ip;

    location / {
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}

来自ngrok的任何请求都将
Host
头设置为ngrok URL。nginx的行为是尝试匹配上面配置中的一个
服务器
块,如果没有
服务器名称
主机
头匹配,则默认为第一个

但是,我猜在
/etc/nginx/conf.d/default.conf
/etc/nginx/sites enabled/0-default
中还有另一个配置文件,它有一个
listen
指令,其中设置了
default\u server
。这将捕获这些请求并提供“欢迎使用nginx!”页面

我建议您查找该文件,并将其删除,这将解决问题

但是,您也可以简化上述配置,只需:

server {
    listen 80;
    server_name localhost;
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}
如果没有另一个
服务器
块隐藏在配置中的其他地方,则使用类似
listen 80 default\u server的指令那么这应该捕获所有请求


有关更多信息,请参阅:

任何来自ngrok的请求都将
主机
头设置为ngrok URL。nginx的行为是尝试匹配上面配置中的一个
服务器
块,如果没有
服务器名称
主机
头匹配,则默认为第一个

但是,我猜在
/etc/nginx/conf.d/default.conf
/etc/nginx/sites enabled/0-default
中还有另一个配置文件,它有一个
listen
指令,其中设置了
default\u server
。这将捕获这些请求并提供“欢迎使用nginx!”页面

我建议您查找该文件,并将其删除,这将解决问题

但是,您也可以简化上述配置,只需:

server {
    listen 80;
    server_name localhost;
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
    }
}
如果没有另一个
服务器
块隐藏在配置中的其他地方,则使用类似
listen 80 default\u server的指令那么这应该捕获所有请求

有关更多信息,请参阅: