我已经在我的VM上在Nginx上部署了我的烧瓶应用程序。
一切都部署好了,我可以在http://my.ip.number上请求apis (我有一个公共IP)
但是当我运行Ngrok (我需要https,并且我没有一个域名来生成SSL证书)时,URL // name .ngrok.io向我展示了Nginx主页(欢迎来到Nginx),而不是我的webapp。
为什么会发生这种情况?
P.D:当我运行"curl localhost“时,我得到了Nginx欢迎页,但是当我执行”curl-4 localhost“时,我得到了我的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;
}
}发布于 2020-01-23 02:12:35
来自ngrok的任何请求都将Host头设置为ngrok。nginx的行为是尝试并匹配上面配置中的一个server块,如果没有server_name匹配Host头,则默认为第一个块。
但是,我猜在/etc/nginx/conf.d/default.conf或/etc/nginx/sites-enabled/0-default中还有另一个配置文件,它有一个带有default_server集合的listen指令。这将捕获这些请求,并为“欢迎来到nginx!”页面。
我建议你去找那个文件,然后删除它,这样就可以解决这个问题了。
但是,您也可以简化上面的配置,只需:
server {
listen 80;
server_name localhost;
location / {
include proxy_params;
proxy_pass http://unix:/home/datascience/chatbot-cima/chatbot.sock;
}
}如果没有另一个server块隐藏在配置中的其他地方,并使用像listen 80 default_server;这样的指令,那么这将捕获所有请求。
有关更多信息,请参见:nginx如何处理请求
https://stackoverflow.com/questions/59868615
复制相似问题