Ghost in a subdirectory and over node-http-proxy

Daren

I'm trying to setup the Ghost blogging program (v0.4) in a subdirectory of another nodejs/express app. I was able to get it working following the steps outlined here: Node http-proxy and express

So, I setup the proxy to Ghost from my main app via Express like this (on my dev machine):'

var proxy = new httpProxy.createProxyServer();
server.get('/blog*', function (req, res, next) {
    proxy.web(req, res, {
        target: 'http://localhost:2368'
    });
});

This works to access the blog content. However, when I go to /blog/ghost/signin and try to login, I get a 404. As far as I can tell, the signin page doesn't go anywhere outside of the blog/ directory, so why would it fail?

If I view the blog directly (on port 2368), I can login just fine.

Alex Lehmann

You have defined a route for GET only, so you are only proxying GET requests, but login and signup uses a POST request. Usually a proxy rule in Apache or nginx will proxy all allowed methods for a given url, but since you defining the handler by method this doesn't happen.

The signup POST gets a 404 since it is handled by your first node application that doesn't know what to do.

In addition to POST you also need the DELETE method to be able click on the notification messages and to delete posts. I'm not sure if other methods are needed as well (OPTIONS), GET, POST and DELETE were the only ones I observed, you will see which method is failing if you take a look at the requests the page does e.g. with Firebug.

To fix this, add the same handler you have added with get for post,put and delete as well:

server.post('/blog*', function (req, res, next) {
    proxy.web(req, res, {
        target: 'http://localhost:2368'
    });
});
server.delete('/blog*', function (req, res, next) {
    proxy.web(req, res, {
        target: 'http://localhost:2368'
    });
});
server.put('/blog*', function (req, res, next) {
    proxy.web(req, res, {
        target: 'http://localhost:2368'
    });
});

This way, the admin interface works correct.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

XML over HTTP与SOAP over HTTP之间的区别

来自分类Dev

使用node-http-proxy从NodeJS到Apache的反向代理不起作用

来自分类Dev

如何获得由node-http-proxy完成的每个代理请求的响应时间?

来自分类Dev

子目录中的Ghost和node-http-proxy

来自分类Dev

如何为传出请求配置node-http-proxy?

来自分类Dev

node.js http-proxy自定义路由

来自分类Dev

使用Node.JS在子域上将Ghost作为NPM模块运行

来自分类Dev

将请求发布到Node-http-proxy Node.js时发生套接字挂断

来自分类Dev

在我的主要Node.js应用程序的子目录中运行Ghost

来自分类Dev

Handling redirects with custom NSURLProtocol and HTTP proxy

来自分类Dev

“ npm start”在ghost(node.js)中给出错误

来自分类Dev

Docker容器中的节点http-proxy

来自分类Dev

带有Ghost 0.7.5,Nginx 1.9,HTTPS和HTTP / 2的ERR_EMPTY_RESPONSE

来自分类Dev

http-proxy-rules和Websockets

来自分类Dev

/node_modules/http-proxy/lib/http-proxy/index.js:120; 错误:套接字挂断

来自分类Dev

如何在node-http-proxy中设置Access-Control-Allow-Headers标头

来自分类Dev

XML over HTTP与SOAP over HTTP之间的区别

来自分类Dev

“ http://ghost.org/”html/css的工作方式

来自分类Dev

谁在设置http_proxy?

来自分类Dev

子目录中的Ghost和node-http-proxy上的Ghost

来自分类Dev

使用harmon在node-http-proxy中修改HTML响应-无输出运算

来自分类Dev

如何为传出请求配置node-http-proxy?

来自分类Dev

node.js http-proxy自定义路由

来自分类Dev

node-http-proxy proxy.on('proxyReq'...)永远不会触发

来自分类Dev

CentOS http_proxy与https_proxy

来自分类Dev

http_proxy设置中的额外http

来自分类Dev

django-http-proxy斜杠

来自分类Dev

node-http-proxy POST请求超时

来自分类Dev

即使Ghost / Node处于开发模式,刷新浏览器后,为什么我的官方Ghost.org Docker容器仍可提供旧内容?

Related 相关文章

  1. 1

    XML over HTTP与SOAP over HTTP之间的区别

  2. 2

    使用node-http-proxy从NodeJS到Apache的反向代理不起作用

  3. 3

    如何获得由node-http-proxy完成的每个代理请求的响应时间?

  4. 4

    子目录中的Ghost和node-http-proxy

  5. 5

    如何为传出请求配置node-http-proxy?

  6. 6

    node.js http-proxy自定义路由

  7. 7

    使用Node.JS在子域上将Ghost作为NPM模块运行

  8. 8

    将请求发布到Node-http-proxy Node.js时发生套接字挂断

  9. 9

    在我的主要Node.js应用程序的子目录中运行Ghost

  10. 10

    Handling redirects with custom NSURLProtocol and HTTP proxy

  11. 11

    “ npm start”在ghost(node.js)中给出错误

  12. 12

    Docker容器中的节点http-proxy

  13. 13

    带有Ghost 0.7.5,Nginx 1.9,HTTPS和HTTP / 2的ERR_EMPTY_RESPONSE

  14. 14

    http-proxy-rules和Websockets

  15. 15

    /node_modules/http-proxy/lib/http-proxy/index.js:120; 错误:套接字挂断

  16. 16

    如何在node-http-proxy中设置Access-Control-Allow-Headers标头

  17. 17

    XML over HTTP与SOAP over HTTP之间的区别

  18. 18

    “ http://ghost.org/”html/css的工作方式

  19. 19

    谁在设置http_proxy?

  20. 20

    子目录中的Ghost和node-http-proxy上的Ghost

  21. 21

    使用harmon在node-http-proxy中修改HTML响应-无输出运算

  22. 22

    如何为传出请求配置node-http-proxy?

  23. 23

    node.js http-proxy自定义路由

  24. 24

    node-http-proxy proxy.on('proxyReq'...)永远不会触发

  25. 25

    CentOS http_proxy与https_proxy

  26. 26

    http_proxy设置中的额外http

  27. 27

    django-http-proxy斜杠

  28. 28

    node-http-proxy POST请求超时

  29. 29

    即使Ghost / Node处于开发模式,刷新浏览器后,为什么我的官方Ghost.org Docker容器仍可提供旧内容?

热门标签

归档