This was working (or it appeared to be) earlier today, but I restarted my server recently, and now Apache seems to not be acknowledging my port 80 vhost.
My site is served from /var/www/example.com/public_html, and port 80 should be redirecting to HTTPS. Before my server restart, this was working; now it's not redirecting and is serving the default content from /var/www/html.
I'm not sure if there's some process or service I may have needed to start after the server restart? The site is enabled and the port 443 vhost is working as expected. Apache version is 2.4.27 and OS is Ubuntu 17.10. This my conf file in /etc/apache2/sites-available/example.com.conf.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
</VirtualHost>
<VirtualHost *:443>
SSLEngine On
SSLCertificateKeyFile /etc/ssl/private/example_com.key
SSLCertificateFile /etc/ssl/certs/example_com.crt
SSLCertificateChainFile /etc/ssl/certs/example_com.ca-bundle
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ProxyPreserveHost On
ProxyPass /api http://localhost:1337/api
ProxyPassReverse /api http://localhost:1337/api
<directory /var/www/example.com/public_html/>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html [L]
</IfModule>
</directory>
</VirtualHost>
Best Answer
Do you have the following in your config(s) somewhere?
Those need to match what you use in the
<VirtualHost>
blocks