skip to Main Content

I’m currently hosting a node app on Elastic Beanstalk. Also, I have a wordpress.com blog. For SEO reasons I want to serve the blog from mysite.com/blog. I could accomplish this through hosting everything on one server fronted by nginx with appropriate rewrite rules. Is there a way I can proxy /blog traffic to the wordpress site and/or a self-hosted wordpress instance and thus keep my EB setup? Any other elegant solutions?

2

Answers


  1. Chosen as BEST ANSWER

    I solved this problem by setting up a self-hosted wordpress instance and then updating my Elastic Beanstalk nginx configuration to reverse-proxy to it. I had to add this line to the configuration, within the server section

    location /blog {
        proxy_pass http://my_blog_address/blog
    }
    

    To get this into the config file in a repeatable way, requires some hacking. The easiest way I found was based on this SO question. Basically, you add a hook to alter the config file during EB initialization.


  2. First: I doubt you will be able to proxy traffic back to your WordPress site while it is hosted on WordPress.com, so you probably will have to setup your own self hosted WordPress install or use a managed WordPress hosting company.

    Second: You can absolutely setup a server, with NGINX and WordPress installed. NGINX would send any requests for the /blog location to php-fpm or whatever php processor you use. Everything else can be proxied to EB.

    Your config would probably look something like this:

    server {
            listen 443 default;
            listen [::]:443;
    
            server_name foo;
            root /path/to/www/;
            index index.php ...;
    
            ... ssl and other stuff ...
    
            proxy_pass ... to EB by default ...
    
            location /blog {
                ... use php ...
            }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search