0

Backend: "Bitnami WordPress with NGINX and SSL Stack for Google Cloud Platform" from marketplace.

I used this guide: https://www.am22tech.com/google-cloud-cdn-wordpress/

I ended up with a somewhat working system as follows:

My Domain ->(google managed cert)-> CDN + Load Balancer -> Instance Group ->(http)-> VM with bitnami stack.

All works well and seems very fast. The biggest gap in my understanding is how the VM can be told it needs to behave as if it's the original domain.

For example, in the nginx server config, any kind of reference to $host seems to return the VM's IP address or something like that.

Also, in wordpress, in a lot of places the domain is replaced by an IP address, even though the site URL and wordpress address show up correctly. This isn't a wordpress question though, as I'm quite sure there is a more general solution I'm missing to do perhaps with NGINX or the load balancer configuration. I think PHP detects the host and passed it along to wordpress but I'm not clear how.

I found a reference somewhere in the google documentation how to manually assign a domain to a VM but not sure that's what's needed here.

Further to this, I'm totally unclear how I would set up https between the vm and the load balancer, yet only have one domain/ip address for the global forward rule. Maybe a separate question.

Steve
  • 883
  • 7
  • 23

2 Answers2

3

Bitnami Engineer here. If you already have the domain, certificates and the Load Balancer in place, you will need to configure WordPress to use that domain name as default domain of the application. You will need to edit the wp-config.php file and configure these lines

define('WP_SITEURL', 'http://DOMAIN/');
define('WP_HOME', 'http://DOMAIN/');

More info: https://docs.bitnami.com/google/apps/wordpress-pro/administration/configure-domain/

In case you also want NGINX to redirect you your domain, no matter how you access your app's information, you can add this configuration line

  return 301 https://DOMAIN$request_uri;

in the /opt/bitnami/nginx/conf/bitnami/bitnami.conf file

More info: https://docs.bitnami.com/google/apps/wordpress-pro/administration/force-https-nginx/

Jota Martos
  • 4,548
  • 3
  • 12
  • 20
  • Thanks, I will try it now! So is there no way to avoid hard-coding the domain in wp-config.php? – Steve Feb 13 '19 at 17:23
  • Note I was able to successfully redirect HTTP to HTTPS by adding an line to my https server block (since I've now configured the google load balancer to talk to my VM via https instead of http, so the http server block isn't being hit anymore): if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; } – Steve Feb 14 '19 at 17:55
0

I had better luck having the load balancer talk to my VM with https. Once I got that working, I didn't have to make any changes to wp-config.php. In this case I didn't bother with varnish because I think it only supports http. I'm hoping google's CDN will be sufficient regarding caching, and I may try a helper plugin in wordpress.

To redirect http to https, I followed the bitnami instructions to set up to front ends to the load balancer pointing to the same static ip address, then in my nginx server blocks, I added a redirect line in the https block (not the http block), since the google load balancer communicates with my backend via https. Google sets the http_x_fowward_proto to http so I check that and redirect if necessary.

if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }

The bitnami stack is amazing, everything seems extremely fast!

Steve
  • 883
  • 7
  • 23