更改了vhost并在CouchDB中重写,无法访问内部API [英] Changed vhost and rewrite in CouchDB and can't access the internal API

查看:52
本文介绍了更改了vhost并在CouchDB中重写,无法访问内部API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将自定义域映射到设计文档_rewrite。

  //配置

虚拟主机www.myapp.com / myapp / _design / user / _rewrite

//重写

[{
from:,
到: static / browser / index.html
},{
from: *,
to: *
}]

第一条路线运行良好。我可以通过www.myapp.com访问index.html。但是,现在我无法访问www.myapp.com/_utils。它说在浏览器控制台中找不到_all_dbs。所有其他API也会停止工作。



我想这是因为该路径现在已转换为/ myapp / _design / user / _utils。



我该如何解决?

解决方案

_utils 和其他特殊路径不能很好地与虚拟主机配合使用。最后我检查了一下(我认为是1.0.2版),_ utils将显示Futon UI,但是其对 _all_dbs 的AJAX调用会失败,并且其他都将失败,并且完全混乱。 p>

我建议您将应用与内部管理严格分开。为应用程序使用虚拟主机,但是在访问Futon或其他工具时始终避免虚拟主机



有一些技巧可以避免您的虚拟主机。




  • 使用服务器IP地址代替域名: http://1.2.3.4:5984

  • 如果可能,请使用其他端口: http://www.myapp.com:5984 https://www.myapp.com:6984

  • 添加指向同一沙发的备用DNS条目并使用: http://futon.myapp.com

  • 在域的末尾添加一个点。 http://www.myapp.com./ —这是非常偷偷摸摸的(或聪明的)。这是一个有效的DNS名称,但是CouchDB对待它的方式与 www.myapp.com 不同,因此您不会触发虚拟主机。


I wanted to map my custom domain to a design document _rewrite.

// Configuration

vhosts     www.myapp.com    /myapp/_design/user/_rewrite

// Rewrites

[{
  "from": "",
  "to": "static/browser/index.html"
}, {
  "from": "*",
  "to": "*"
}]

The first route works fine. I can access the index.html with www.myapp.com. However, now I can't access www.myapp.com/_utils. It says _all_dbs can't be found in the browser console. All other APIs stop working as well.

I guess this is because that path is now converted to /myapp/_design/user/_utils.

How can I fix this?

解决方案

_utils and other "special" paths do not cooperate with vhosts very well. Last I checked (version 1.0.2 I think), _utils will display the Futon UI however its AJAX calls to _all_dbs and others will fail and it is a total mess.

I suggest a strict separation between your app and your internal management. Use the vhost for the application, but always avoid vhosts when accessing Futon or other tools.

There are a few tricks to avoid your vhost.

  • Use the server IP address instead of the domain name: http://1.2.3.4:5984
  • Use a different port if possible: http://www.myapp.com:5984 or https://www.myapp.com:6984
  • Add an alternative DNS entry pointing to the same couch and use that: http://futon.myapp.com
  • Add a dot at the end of your domain. http://www.myapp.com./ — This is very sneaky (or clever). That is a valid DNS name however CouchDB treats it differently from www.myapp.com therefore you will not trigger the vhost.

这篇关于更改了vhost并在CouchDB中重写,无法访问内部API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆