Apache 作为 CouchDB 的反向代理

发布于 2024-08-01 19:51:09 字数 229 浏览 5 评论 0原文

我正在考虑一个广泛使用 CouchDB 的 Web 应用程序,尽可能多地使用本机 erlang HTTP API 提供服务会带来巨大收益。

您能否将 Apache 配置为反向代理,以允许外部 GET 直接代理到 CouchDB,而 PUT/POST 发送到应用程序内部逻辑(用于卫生、身份验证...)? 或者这是不明智的——CouchDB 内置身份验证选项对于 Web 应用程序来说似乎有点弱。

谢谢

I'm thinking of a web app that uses CouchDB extensively, to the point where there would be great gains from serving with the native erlang HTTP API as much as possible.

Can you configure Apache as a reverse proxy to allow outside GETs to be proxied directly to CouchDB, whereas PUT/POST are sent to the application internal logic (for sanitation, authentication...)? Or is this unwise -- the CouchDB built-in authentication options just seem a little weak for a Web App.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

峩卟喜欢 2024-08-08 19:51:09

可以使用mod_rewrite 根据HTTP方法有选择地代理请求。

例如:

# Send all GET and HEAD requests to CouchDB
RewriteCond %{REQUEST_METHOD} GET|HEAD
RewriteRule /db/(.*) http://localhost:5984/mydb/_design/myapp/$1 [P]

# Correct all outgoing Location headers
ProxyPassReverse /db/ http://localhost:5984/mydb/_design/myapp/

任何 POSTPUTDELETE 请求都将由 Apache 照常处理,因此您可以按照自己的方式连接应用程序层通常会。

You can use mod_rewrite to selectively proxy requests based on the HTTP method.

For example:

# Send all GET and HEAD requests to CouchDB
RewriteCond %{REQUEST_METHOD} GET|HEAD
RewriteRule /db/(.*) http://localhost:5984/mydb/_design/myapp/$1 [P]

# Correct all outgoing Location headers
ProxyPassReverse /db/ http://localhost:5984/mydb/_design/myapp/

Any POST, PUT, or DELETE requests will be handled by Apache as usual, so you can wire up your application tier however you usually would.

葵雨 2024-08-08 19:51:09

你看到这个了吗? OAuth 和 cookie 身份验证已于 4 日签入:

http://github.com/halorgium/couchdb /commit/335af7d2a9ce986f0fafa4ddac7fc1a9d43a8678

另外,如果您有兴趣使用 Erlang 作为服务器语言,您可以通过 webmachine 代理 couchdb:

http://blog.beerriot.com/2009/05/18/couchdb-proxy-webmachine-resource/

Did you see this? OAuth and cookie authentication were checked in on the 4th:

http://github.com/halorgium/couchdb/commit/335af7d2a9ce986f0fafa4ddac7fc1a9d43a8678

Also, if you're at all interested in using Erlang as the server language, you could proxy couchdb through webmachine:

http://blog.beerriot.com/2009/05/18/couchdb-proxy-webmachine-resource/

热血少△年 2024-08-08 19:51:09

我会考虑使用 Apache mod_proxy 的反向代理功能。 创建一个虚拟主机配置,将 Web 服务器的某些 HTTP 请求转发到 CouchDB。 您可以设置应转发哪些 URI 路径的规则等。

请参阅本指南以获取灵感:http://macgyverdev.blogspot.se/2014/02/apache-web-server-as-reverse-proxy-and.html

I would consider using the reverse proxy feature of Apache mod_proxy. Create a virtual host configuraton that forwards certain HTTP requests of the web server to CouchDB. You can setup rules on which URI paths that should be forwarded etc.

See this guide for inspiration: http://macgyverdev.blogspot.se/2014/02/apache-web-server-as-reverse-proxy-and.html

与风相奔跑 2024-08-08 19:51:09

你的问题已经过时了,没有答案,所以我会添加这个“几乎答案”。

Nginx 绝对可以根据请求进行不同的重定向。

这是,如果您准备将 nginx 放在前端作为 revproxy,并将 apache 和 couchdb 都作为后端。

Your question is aging without answers, so I'll add this "almost answer".

Nginx can definitely redirect differently based on requests.

This is, if you are ready to place nginx in the front as the revproxy and place apache and couchdb both as backends.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文