honk
V2EX  ›  问与答

nginx 反向代理 dropbox的public,如何设置目录索引?

  •  
  •   honk · Dec 30, 2011 · 5799 views
    This topic created in 5317 days ago, the information mentioned may be changed or developed.
    想利用Dropbox的Public目录,放些demo之类
    <pre>
    server{
    listen 80;
    server_name xxx.com;

    location / {
    proxy_pass http://dl.dropbox.com/u/xxxxxxxx/;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }
    </pre>

    这样设置后,可以通过 xxx.com/index.html 访问到 public/index.html .

    我想问的是,如何配置,可以在访问xxx.com/时不加 index.html 也能返回 public/index.html的内容
    4 replies    1970-01-01 08:00:00 +08:00
    honk
        1
    honk  
    OP
       Dec 30, 2011
    试了 在server {} 里加 :
    index index.html

    无效
    honk
        2
    honk  
    OP
       Dec 31, 2011   ❤️ 1
    通过rewrite 解决了 !
    在location / {} 里加:

    set $index index.html;
    rewrite ^.*\/$ $fastcgi_script_name$index last;
    lenmore
        3
    lenmore  
       Dec 31, 2011
    我是这样做的:
    location = / {
    index index.html;
    }

    location / {
    ...
    }
    honk
        4
    honk  
    OP
       Dec 31, 2011
    @lenmore 谢谢!不过,这样对子目录就不行了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1072 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:43 · PVG 06:43 · LAX 15:43 · JFK 18:43
    ♥ Do have faith in what you're doing.