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 · Nov 25, 2018 · 3371 views
    This topic created in 2769 days ago, the information mentioned may be changed or developed.

    看我的 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  
       Nov 25, 2018
    http://localhost:8000 试试
    Hopetree
        2
    Hopetree  
    OP
       Nov 25, 2018
    @shylockhg 可以显示 Django 的首页
    Hopetree
        3
    Hopetree  
    OP
       Nov 25, 2018
    @shylockhg 但是不能显示静态文件啊,因为直接请求 8000 端口就没有经过 nginx 了
    shylockhg
        4
    shylockhg  
       Nov 25, 2018
    哦,那 django 的请求可以正则匹配出来吗。比如~ \.php$什么的
    Hopetree
        5
    Hopetree  
    OP
       Nov 25, 2018
    @shylockhg 已经好了,我没有改任何配置,可能是浏览器有缓存吧,反正刷出来了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1027 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:26 · PVG 02:26 · LAX 11:26 · JFK 14:26
    ♥ Do have faith in what you're doing.