Add SSL to a Dockerzied wordpress container - wordpress

I have two Docker containers (Wordpress and MySQL) and I installed Apache on the server.
So it looks something like this;
I am trying to add an SSL certificate to it with Certbot.
So far, my Apache configuration file is this;
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
And I have added this two lines of code to wp-config.php;
define('WP_HOME', 'http://example.com/');
define('WP_SITEURL', 'http://example.com/');
When I use certbot --apache and choose the domain to add the SSL certificate, the website "brakes"; no CSS, no JS, no images and I can't access to the admin (to try to change http to https using Search and Replace);
I tried to change http with https and add define('FORCE_SSL_ADMIN', true); to wp-config.php but that didn't work;
Do anyone know the perfect way to add an SSL to Dockerized wordpress container?
PS: I tried a desperate move to change manually all the http://example.com to https://example.com in all tables in the database. it didn't work and it is a pretty stupid thing to do, but desperate times call for desperate measures.

This needs to be https, otherwise your assets will load from http resulting in mixed content.
define('WP_HOME', 'https://example.com/');
define('WP_SITEURL', 'https://example.com/);

This is the apache config file from bitnami images, maybe this helps:
<VirtualHost *:80>
ServerName wordpress.example.com
ServerAlias www.wordpress.example.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:443>
ServerName wordpress.example.com
ServerAlias www.wordpress.example.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

Related

XAMPP Wordpress Site is not accessible from production server

My Needs are
1. Configure Multiple Domain on XAMPP server on production (Woocommerce Site)
2. Configure and enable ssl
Steps i followed
Edited httpd-vshost as
NameVirtualHost *:80
ServerAdmin mail#firstsite.in
DocumentRoot "C:/xampp/htdocs/firstsite"
Allow from all
ServerName firstsite.in
ServerAlias www.firstsite.in
ServerAdmin mail#secondsite.in
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secindsite.in
ServerAlias www.secondsite.in
Allow from all
Edited httpd-ssl
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/firstsite"
ServerName firstsite.in:443
ServerAlias www.firstsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\mibstore\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\mibstore\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\mibstore\server.key"
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin admin#localhost
DocumentRoot "C:/xampp/htdocs/secondsite"
ServerName secondsite.in:443
ServerAlias www.secondsite.in:443
ErrorLog "logs/example-error.log"
CustomLog "logs/example-access.log" common
SSLEngine on
SSLCACertificateFile "C:\xampp\apache\conf\ricebazzar\ca_bundle.crt"
SSLCertificateFile "C:\xampp\apache\conf\ricebazzar\server.crt"
SSLCertificateKeyFile "C:\xampp\apache\conf\ricebazzar\server.key"
</VirtualHost>
I have obtained SSL certificate from sslforfree and stored them on relevant path
I also edited etc\hosts file
127.0.0.1 firstsite.in
127.0.0.1 secondsite.in
Issue
I can able to browse them from the server(windows) itself , but can't able to access them from outside. the relevant domain names are purchased and added a A record to point the IP.
Notes
Using Amazon AWS EC2 instance
Added Inbound Rules on 80 & 443, And also added firewall rules on 80 & 443
Would you tried in another PC to visit them since you changed your host file on your PC.
If they can be visited then you need remove the record of your host file.
If not, please try:
Does both the A record of WWW and Non-WWW have been pointed to IP.
If pointed, please tell me what error or message you see on browser when you load the websites.
If there're no error or message which means they are blank page, please try to check is there any htaccess file, do you enable the rewrite mod of xampp.

How to run different website in a same domain with HTTP and HTTPS

Can i run different websites in same domain. like
http://www.example.com ----> in WordPress
https://example.com/ -----> in laravel
Here is the reference site
Website : www.linqs.in
APP: https://linqs.in/username
App url will open user's profile by provided username.
sorry if i made mistake !! if this possible please guide me.
You can do this in your virtual host configuration:
Listen 80
Listen 443
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/path/to/wordpress"
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot "/path/to/laravel/public"
</VirtualHost>
You may also need to define directories if the sources are not under your default http root. For example:
<VirtualHost *:443>
ServerName example.com
DocumentRoot "/path/to/laravel"
<Directory /path/to/laravel>
AllowOverride All
</Directory>
</VirtualHost>
This will also allow Apache to serve that directory and use any .htaccess files (if it wasn't allowed already).
Since URL listen on port like http - port 80, https - port 443. So, you can ensure different website in a same domain via VirtualHost configure.

How to redirect a domain to different server's subdomain?

May this question or relevants asked before but I need to finish this issue properly. So let me explain what i want;
1- I've create and designed a wordpress project my own server subdomain ( eg: xyz.proje.com)
2- I've a domain (eg: www.xyz.com) which bought different company.
3- The project will remain my own server but the domain need to redirect this subdomain.
So how can i do this properly? How can change all xyz.proje.com ( and sub pages etc) links to www.xyz.com in this project?
Thanks.
Do you checked Create A Network in wordpress?
or Edit apache Virtual Host?
Listen 80
<VirtualHost *:80>
DocumentRoot /www/mainsite
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/subdomain1
ServerName subdomain1.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/subdomain2
ServerName subdomain2.example.org
# Other directives here
</VirtualHost>

Issu with varnish-ban-manager installation, using vhost in AWS

I've installed varnish-ban-manager (https://github.com/dot2code/varnish-bans-manager) and I'm currently configuring it's DNS name.
The thing is that I've set in Route53 (DNS service in AWS) to use name http:// purge.domain.com / pointing to http:// varnish_server_name.com/. The thing is, if I test with http :// purge.domain .com:9000/ it works normally, but using http: //purge.domain.com/ will send me a "your request cannot be processed" (in a varnish error screen).
Any ideas why this could be happening? I've test this with the ip address of this vm and works perfectly too..
Here's the vhost config file:
<VirtualHost *:80>
ServerName purge.domain.com
ServerAlias purge.domain.com
ProxyPass / http://varnish_server.domain:9200/
ProxyPassReverse / http://purge.domain.com/
# Logging
ErrorLog logs/server-error_log
CustomLog logs/server-access_log combined
</VirtualHost>
Note: i've replaced my real domain for "domain" just in case.
Thanks guys!!
Solved. I've added some lines to vhost:
ServerName http:// purge.comain.com
ProxyPass / http:// varnish_server:9000/
ProxyPassReverse / http:// varnish_server:9000/
ErrorLog logs/purge. cloud-turner.com.ar-error_log
CustomLog logs/purge. cloud-turner.com.ar-access_log combined
And added proxy.conf (/etc/httpd/conf.d/) with this line
ProxyPreserveHost on
And that's it!

EC2 AWS SSL issue in Wordpress for load assets

I have a wordpress blog in AWS that uses http.
Now I instaled a SSL certificate so I can use https.
All http://www.mysite.com works fine. All content loads and is perfect.
When I use https://www.mysite.com, all assets (images, css, js,..) are not loaded and got a console error that the server can't find in https.
Does anyone know a possible solution for this?
Installed mod_sll, restarted Apache, update yum, open port 443.... But nothing.
Thanks in advance
Seems like you didn't properly setup the SSL virtual host. if you use default ssl.conf in apache, make sure you add ServerName and ServerAlias accordingly.
If it still didn't work. Please backup your ssl.conf first and delete all the lines below
## SSL Virtual Host Context in ssl.conf and put following content in ssl.conf or as a new file in sites-enabled if you're using debian based.
Also dont forget to run netstat -nltp and see if port 443 is listing by apache. If not add listen 443 in your httpd.conf or ssl.conf
<VirtualHost *:443>
SSLEngine on
SSLProtocol -ALL +SSLv3 +TLSv1
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:!LOW:!SSLv2:!EXPORT
## /etc/httpd/ssl/ replace with the directory which contains your PrivateKey,
## Certificate and Bundle file(if available)
SSLCertificateFile /etc/httpd/ssl/ssl.crt/your_domain.crt
SSLCertificateKeyFile /etc/httpd/ssl/ssl.key/your_domain.key
SSLCACertificateFile /etc/httpd/ssl/ssl.crt/bundle.crt
ServerName yourdomain.com
ServerAlias www.yourdomain.com
ServerAdmin youremail.com
DocumentRoot /var/www/yourdomain.com/htdocs
php_admin_value open_basedir "/var/www/yourdomain.com/htdocs"
<Directory "/var/www/yourdomain.com/htdocs" >
Options -Indexes FollowSymLinks
allow from all
AllowOverride All
</Directory>
CustomLog /var/log/httpd/yourdomain-access_log combined
ErrorLog /var/log/httpd/yourdomain-error_log
</VirtualHost>

Resources