couchdbのプロキシフロントエンドとしてnginx 0.6.32を実行しています。私はデータベースにrobots.txtを持っていて、http://www.example.com/prod/_design/mydesign/robots.txtという名前でアクセス可能です。同様のURLに動的に生成されたsitemap.xmlもあります。robots.txtとsitemap.xmlのURLにリダイレクトするようにnginxを設定するには
私は、次の設定を試してみました:
server {
listen 80;
server_name example.com;
location/{
if ($request_method = DELETE) {
return 444;
}
if ($request_uri ~* "^/robots.txt") {
rewrite ^/robots.txt http://www.example.com/prod/_design/mydesign/robots.txt permanent;
}
proxy-pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
これは、リダイレクトとして動作しているように見えますが、簡単な方法はありますか?
これは最も簡単な解決策のようですが、完璧に動作します。 – Gattster
'directory-containing-file'と言うと、私はあなたがファイル名*を含んでいると思いますか?私はエイリアス/ www/static;を試しましたが、スラッシュの有無にかかわらず失敗しました。私が 'alias /www/static/robots.txt;'を使用したとき、うまくいきました。 –
John C - いいえ、ディレクトリだけです。 'alias/directory;を置くのではなく' root/opt/directory /; 'とすることもできます。 – PlanetUnknown