How do I Create a Node.js proxy server routing to Wordpress(apache)?

December 21, 2016 564 views
Apache Node.js WordPress Ubuntu

Hey Everyone,

I was reading this article about an interesting server setup ->
https://www.sitepoint.com/universal-react-rendering-sitepoint

I'm wondering what do I need to do in order to set something like this up? Are there any tutorials on here that fit that description? Any help in figuring out this server setup would be awesome!

Thanks,
Spencer

1 Answer

Hi!

There isn't any tutorial on DO talking about routing React/WP app.

If you didn't already saw, at bottom of above post, there is source code for sample app.
Referencing above article and source code can be helpful to build same setup.

However, this would require better Node.js, JS, WP/PHP knowledge so you can understand above code. :)
If you need help with any part, feel free to ask, maybe someone will come with solution. ;)

  • Ok I will definitely keep searching to find out more about there code base. My next question is where can I go to learn how to setup a node.js proxy to an apache server? I'm having hard time finding a good walkthrough on this...

    • I know you're having hard time finding a good tutorial. It's not something you'll see frequently. Usually, you'll find how to make reverse proxy so Apache serves your app. As there isn't direct tutorial, you'll have to analyze part by part.

      The point of set up you want is rendering. You want to send request to Node.js server for specific pages. When it receive request, it should render page server-side and return it to you. So what you want - web page parsing using Node.js. If you're new to Node, start with basics. Learn how it works, build sample server that return Hello, World!. If you have idea for something more complex, just do it.
      When you see Hello, World!, it means that you parsed basic HTML code. That's just beginning. Learn how to do it for file then how to do it from Apache (by making HTTP request).

      That's basic step to get you into Node world if you are new to it. After this look more at source code and try to find how to parse JavaScript and render it.
      When you do this, you basically have setup you want.

      • Ok I will start there with basic Node.js - I am definitly new to node so a great area to start in. Maybe I will answer my one question once I get more familiar with Node and rendering + http requests.

        Thanks so much xMurdii.

Have another answer? Share your knowledge.