V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Hopetree
V2EX  ›  NGINX

docker 配置了 django+nginx 之后,发现其他页面都可以显示 django 的页面,但是首页一直都是 nginx 的欢迎页面,而不是 Django 服务的首页

  •  
  •   Hopetree ·
    Hopetree · 2018-11-25 17:47:12 +08:00 · 2638 次点击
    这是一个创建于 1950 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看我的 nginx 的配置 /etc/nginx/conf.d/nginx.conf

    server {
        # 端口和域名
        listen 80;
        server_name localhost;
    
        # 不记录访问不到 favicon.ico 的报错日志
        location = /favicon.ico {
            access_log off;
            log_not_found off;
        }
    
        # static 和 media 的地址
        location /static/ {
            root /usr/share/nginx/izone;
        }
        location /media/ {
            root /usr/share/nginx/izone;
        }
    
        # web 服务
        location / {
            proxy_pass http://web:8000;
        }
    }
    

    是哪个地方没有设置好么,为什么其他的页面都正常显示

    shylockhg
        1
    shylockhg  
       2018-11-25 18:56:25 +08:00
    http://localhost:8000 试试
    Hopetree
        2
    Hopetree  
    OP
       2018-11-25 19:30:18 +08:00
    @shylockhg 可以显示 Django 的首页
    Hopetree
        3
    Hopetree  
    OP
       2018-11-25 19:31:05 +08:00
    @shylockhg 但是不能显示静态文件啊,因为直接请求 8000 端口就没有经过 nginx 了
    shylockhg
        4
    shylockhg  
       2018-11-25 19:45:58 +08:00
    哦,那 django 的请求可以正则匹配出来吗。比如~ \.php$什么的
    Hopetree
        5
    Hopetree  
    OP
       2018-11-25 22:03:11 +08:00
    @shylockhg 已经好了,我没有改任何配置,可能是浏览器有缓存吧,反正刷出来了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3088 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:52 · PVG 20:52 · LAX 05:52 · JFK 08:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.