我正在运行nginx 0.6.32作为couchdb的代理前端.我在数据库中有我的robots.txt,可以访问http://www.example.com/prod/_design/mydesign/robots.txt.我也有类似网址上动态生成的sitemap.xml.
我试过以下配置:
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;
}
Run Code Online (Sandbox Code Playgroud)
这似乎是一个重定向,但有一个更简单的方法吗?