I have WP multisite, ACM Issued SSL, Load Balancer Setup, how to provide HTTPS access to users? - wordpress

Has anyone with a WP multisite been through this process? I have created the Load Balancer and have a domain (one of the multisite sites) on an EC2 instance.
My load balancer setup looks like this:
Going to https://foobar.com just times out and going to https://www.foobar.com just ignores the SSL request. Is there a step I'm missing? Maybe something in httpd.conf or wp-config?
I'm sure someone has gone through something similar, it would help us all dealing with such an issue. I feel like going with WPEngine would've made much more sense than AWS for an simple WP site :(

Looks like you load balancer is setup with SSL termination as I can see you're forwarding the traffic to http target group, not https, do you have self-certified SSL.
you wanna make sure in your wp-config.php to detect SSL :
// Update 8-April-2018: I moved https redirection from the Apache virtual
server config to wp-config.php using this snippet.
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
for more details, check the link : https://blog.lawrencemcdaniel.com/wordpress-aws-elb-ssl/

Related

Nginx as Reverse Proxy for Prestashop

I have this scenario with Nginx as reverse proxy and Prestashop:
I have Prestashop installed as a container with Proxmox and it has been configured with a local IP address (192.168.0.10) instead of a domain name. I can access Prestashop via the local IP without problems through the local network.
I have nginx as a reverse proxy installed on another VM that receives the request with a domain name (subdomain.example.com) with an SSL certificate on the Nginx, and makes a proxy_pass for the local IP address (192.168.0.10).
When the request is made via the external domain Prestashop redirects [subdomain.example.com] to [192.168.0.1] which is not expected.
With other attempts returns the error (too many redirects) ...
other attempts returns the error 500 ...
I've already tried to enable SSL on prestashop, assign the domain [subdomain.example.com] on prestashop, activate multistore and several other attempts without any success.
I found a tutorial that suggest do edit de [Link.php] file on Prestashop but don't work for me too.
I can't find any material on the web that solves this problem, nor in the Prestashop documentation, so I ask for your help.
This is probably a misconfiguration in Prestashop as your webserver config is pretty straightforward.
Please make sure :
that your DB table ps_shop_url is containing the correct subdomain.example.com in domain and domain_ssl row.
that .htaccess file in Prestashop in root folder is not containing references to your backend IP (192.168.0.1) - If this is the case, you'll need to regenerate in from backoffice (click SAVE in Seo&URL tab )

WP site accessible at subpath of domain used by Squarespace site

Alright this is a super weird request and it's just a stopgap measure until the client cleans up their many web properties, so no need to tell me that it's a convoluted way to do things. Current setup:
example.com is registered with GoDaddy but points to a Squarespace
site (CNAME & A records, etc)
sub.example.com is a Wordpress site on Godaddy hosting
Question: Can I make the WP site at sub.example.com instead appear as example.com/sub? If so, how?
I can set the site_url and home_url in WP, and I can set up a forwarding rule from Squarespace to the IP of the GoDaddy shared hosting account. Would that be enough?
I had thought I would need to set an A record with the host as example.com/sub, but slashes aren't allowed. Any insight greatly appreciated. Thanks for reading!
the only way to get this done that I am aware, is to use some form of land balancer, e.g.:
AWS Elastic Load balancer
Nginx / apache proxy
AWS CloudFormation custom backends
last option will also speed up your site.
Unless your DNS provider have some custom option, DNS alone can't do that.

How to set up a Google VM (instance grouped), https load balanced w/CDN, so that the backend resolves the domain?

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.
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/
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!

Wordpress get_template_directory_uri() behind load balancer

I have a Wordpress website running on an AWS EC2 instance. This is served through an AWS Elastic Load Balancer, which has HTTPS enabled with a certificate I got from Amazon.
The intention is to serve both an http and an https version of the website. Loading the http version works fine.
When I load the https version however, I'm getting mixed content errors because get_template_directory_uri() always returns http links. The way the load balancer works is the TLS terminates at the LB, and it communicates with the actual EC2 instance over port 80. therefore, there is no HTTPS on the instance itself.
A lot of this is beyond my skill to heal. I know just enough to have figured out what the problem seems to be, but I'm really not sure what the right way to fix it is.
Assuming I still want to serve both http and https versions of the page (there is no ecommerce or auth on the page -- it's just informational), how should I go about fixing this?
FYI, the EC2 instance is running on an Amazon ABI, which is basically RHEL.
So first off, you will find it difficult to run both an http and https WordPress version off the same database data because WordPress saves a lot of links as absolute links (i.e. with the http(s)://mydomain.com part) and a lot of plugins just don't bother adapting to the current protocol either.
Your best bet is going to be doing redirects through your htaccess file to redirect all http traffic to https.
That being said, one way you could do what you asked for is through a filter used by get_template_directory_uri:
add_filter('template_directory_uri', 'smart_template_directory_uri', 10, 3);
function smart_template_directory_uri($template_dir_uri, $template, $theme_root_uri) {
return preg_replace('/^https?\:/i', '//', $template_dir_uri); // replace "http://" or "https://" by "//", which browsers will automatically set to the current page's protocol
}
Hope this helps!

How to enable and accept HTTPS connections and setup SSL certificates on GCE

I am using Google Compute Engine, I have a VM instance with wordpress installed.
I want to enable HTTPS, I have cloudflare ssl for the domain, but as soon as I turned on ssl in wordpress (setting siteurl to https://domain.com) it fudges up and wont load any longer.
Ive tried looking very hard through Google cloud documentation, cant find anything that helps.
All I want is to install an SSL cert on my instance, allow https connection through and get on with setting up the rest of my site!
But it seems there is no way to do this?
ANy help will be greatly appreciated,
thankyou
I think you should set "Allow HTTPS traffic" on VM Instance's settings page

Resources