我有一个网站主机在一个服务器上的数字海洋,这是奇怪的行为。
该网站是用Flask编写的,它部署在Docker中,并使用反向代理,结合使用加密来在web上托管。
该网站的域名是mes.th3pl4gu3.com。
如果我上了mes.th3pl4gu3.com/web/
,网站就会出现并正常工作。
如果我继续使用mes.th3pl4gu3.com/web
,它会给我URl中的http://localhost/web/
,而conenction失败了。
但是,当我在本地运行它时,它工作得很好。
我检查了我的nginx日志,当我浏览mes.th3pl4gu3.com/web/
时,access_logs返回成功,但是当我使用mes.th3pl4gu3.com/web
时,日志中什么都没有。
有人知道是什么导致了这一切吗?
下面是一些可能有助于故障排除的代码。
server {
server_name mes.th3pl4gu3.com;
location / {
access_log /var/log/nginx/mes/access_mes.log;
error_log /var/log/nginx/mes/error_mes.log;
proxy_pass http://localhost:9003; # The mes_pool nginx vip
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/..........
ssl_certificate_key /etc/letsencrypt/........
include /etc/letsencrypt/.........
ssl_dhparam /etc/letsencrypt/......
}
server {
if ($host = mes.th3pl4gu3.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mes.th3pl4gu3.com;
return 404; # managed by Certbot
}
码头实例:
7121492ad994 docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:1.2.5 "uwsgi
app.ini" 4 weeks ago Up 4 weeks 0.0.0.0:9002->5000/tcp mes-instace-2
f4dc063e33b8 docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:1.2.5 "uwsgi app.ini" 4 weeks ago Up 4 weeks 0.0.0.0:9001->5000/tcp mes-instace-1
fb269ed2229a nginx "/docker-entrypoint.…" 4 weeks ago Up 4 weeks 0.0.0.0:9003->80/tcp nginx_mes
2ad5afe0afd1 docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:1.2.5 "uwsgi app.ini" 4 weeks ago Up 4 weeks 0.0.0.0:9000->5000/tcp mes-backup
docker-compose-instance.yml
version: "3.8"
# Contains all Production instances
# Should always stay up
# In case both instances fails, backup instance will takeover
services:
mes-instace-1:
container_name: mes-instace-1
image: "docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:${MES_VERSION}"
networks:
- mes_net
volumes:
- ./data:/app/data
env_file:
- secret.env
ports:
- "9001:5000"
restart: always
environment:
- MES_VERSION=${MES_VERSION}
mes-instace-2:
container_name: mes-instace-2
image: "docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:${MES_VERSION}"
networks:
- mes_net
volumes:
- ./data:/app/data
env_file:
- secret.env
ports:
- "9002:5000"
restart: always
environment:
- MES_VERSION=${MES_VERSION}
networks:
mes_net:
name: mes_network
driver: bridge
docker-compose.yml
version: "3.8"
# Contains the backup instance and the nginx server
# This should ALWAYS stay up
services:
mes-backup:
container_name: mes-backup
image: "docker.pkg.github.com/mervin16/mauritius-emergency-services-api/mes:${MES_VERSION}"
networks:
- mes_net
volumes:
- ./data:/app/data
env_file:
- secret.env
ports:
- "9000:5000"
restart: always
environment:
- MES_VERSION=${MES_VERSION}
nginx_mes:
image: nginx
container_name: nginx_mes
ports:
- "9003:80"
networks:
- mes_net
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./log/nginx:/var/log/nginx
depends_on:
- mes-backup
restart: always
networks:
mes_net:
name: mes_network
driver: bridge
我有多个跨应用程序的负载平衡实例。
有人能帮忙吗?如果有人知道为什么会发生这种事?
发布于 2021-04-14 03:40:16
只要我测试了页面https://mes.th3pl4gu3.com/web,到底有没有/
尾随,它就能正常工作。(Ubuntu上的Firefox版本87 )
可能您的、web浏览器、或您正在运行的任何类型的虚拟专用网/代理都有错误/问题。确保他们都走了。
此外,在Nginx上,可以使用rewrite
规则消除跟踪/
。
例如:
location = /stream {
rewrite ^/stream /stream/;
}
它告诉Nginx解析stream
,因为它是stream/
。
为了确保您不会因为缓存的数据而面临任何问题,请禁用和清除所有缓存。在你的浏览器点击F12
->到console选项卡,点击F1
,在那里禁用缓存。在Nginx上为报头设置“无缓存”。
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
发布于 2021-04-14 03:47:54
我用Chrome,Safari和Curl测试了你的网站,我看不出这个问题。
试着清理你的缓存。
方法1: Ctrl-Shift-R
方法2: DevTool ->应用程序/存储->清除站点数据
发布于 2021-04-10 19:20:19
我猜是和你的酒瓶SERVER_NAME
有关
正如您所说的,本地SERVER_NAME可能被设置为localhost:8000。
然而,在生产上,它需要类似于
SERVER_NAME = "th3pl4gu3.com"
您的问题是,您正在从SERVER_NAME变量中提取SERVER_NAME,因此它最终成为https://localhost/web而不是您想要的URL。
https://stackoverflow.com/questions/67037770
复制相似问题