EC2 AWS SSL issue in Wordpress for load assets - wordpress

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>

Related

How can I install SSL on an EC2 instance

I have my Wordpress site running on a Ec2 instance , How can connect with it using http.
I have done below configuration in .conf file. Everything in Ec2 file, I can see if I use Bitnami AMI it is very easy to configure but not sure or getting any document which says how we do it in Ec2. Also to note that I have my DNS and nameserver in AWS rOUTE53
I want a secure connection to my website
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Add SSL to a Dockerzied wordpress container

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>

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.

IIS & XAMPP Conflict, Ports Already Changed

I have IIS enabled (fresh "install") and a port configured XAMPP install with a fresh Wordpress build.
httpd.conf (changes):
Listen 8080
ServerName localhost:8080
httpd-ssl.conf (changes):
Listen 4433
<VirtualHost _default_:4433>
ServerName www.example.com:4433
httpd-vhosts.conf (changes):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs/foobar"
ServerName foo.bar
<Directory "C:/xampp/htdocs/foobar">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
hosts (changes):
127.0.0.1 localhost
127.0.0.1 foo.bar
Tests:
http://localhost/
IIS Root (expected)
http://localhost:8080/[dashboard]
XAMPP Root (expected)
http://localhost:8080/foobar
resolves to http://localhost/foobar, displays IIS error page (incorrect, should show the Wordpress install)
http://foo.bar
displays IIS root (incorrect, should show Wordpress install)
http://foo.bar:8080
resolves to http://foo.bar (same result as above)
Honestly, at this point I have no idea what I have setup that is incorrect. I've spent all day reading forums and SO, and I'm not making any headway. Help? Am I making incorrect assumptions on behavior or do I have a mistake in my setup?
Assuming that you want both services running at the same time, that you'll mostly be working with XAMPP. This is my solution:
I'm not a fan of typing in port 8080 whenever I want to be working with XAMPP. So I just changed the post number of IIS to 82.
Start IIS (7) On the left go to YOUR MACHINE > Sites > Default Web Site
Then on the right click on bindings then a window pops up
Click on the first row and edit the port number to anyting but 80 (because 80 is the default port if you don't type in anything in
your browser)
Reset all the settings of httpd.conf, httpd-ssl.conf
Then open httpd-vhosts.conf and put this:
<VirtualHost *:80>
DocumentRoot C:\xampp\htdocs\foobar
ServerName foo.bar
</VirtualHost>
Restart your computer (httpd-vhosts.conf doesn't take effect without)
The file hosts is fine as it is.

Setting Up WordPress MS Locally with Port 8888 with XAMPP

I have installed XAMPP and edited the httpd.conf file because my port 80 is busy.
So I have the following:
Listen 0.0.0.0:8888
Servername localhost:8888
Everything works fine until I try to install WordPress 3.0.5 MS because it will not accept ports in the name.
So I have tried to add .htaccess file to my htdocs that contains:
RewriteEngine on
RewriteRule ^:8888/(.*)$ /$1 [L]
But that did not work.
So I have tried to create Virtual Hosts in httpd.conf adding the following at the bottom:
<Directory "C:/xampp/htdocs/www/wp.dev">
Order Deny,Allow
Allow from all
</Directory>
<Directory "C:/xampp/htdocs/">
Order Deny,Allow
Allow from all
</Directory>
NameVirtualHost 127.0.0.1:8888
<VirtualHost 127.0.0.1:8888>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost2
</VirtualHost>
<VirtualHost 127.0.0.1:8888>
DocumentRoot "C:/xampp/htdocs/www/wp.dev"
ServerName wp.dev
</VirtualHost>
And then I added the following to my hosts file (Help):
127.0.0.1:8888 localhost2
127.0.0.1:8888 wp.dev
And that hasn't worked. I cannot use port 80 as an option, so I need to figure this out. So what am I doing wrong?
Unfortunately WordPress MS requires port 80 to work. You can check the requirements in this link
If using that port in your local machine is not an option for you, what you could consider is to work with a Virtual Machine. (This is the link to the BitNami WordPress virtual appliance in case you want to try it.)

Resources