I've been struggling around to get my website running with HTTP redirect https and ssl.
Apache 2.4.41
Ubuntu 20.04 LTS
Current data:
iptables -> https://www.toptal.com/developers/hastebin/acufujubuz.sql
It was a bit long so I decided to paste it in a url
UFW ->
Status: active
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
VS ->
<VirtualHost *:80>
ServerName <mydomain>
ServerAlias www.<mydomain>
Redirect permanent / https://<mydomain>/
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.<mydomain> [OR]
RewriteCond %{SERVER_NAME} =<mydomain>
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin <mydomain>
ServerName <mydomain>
ServerAlias <mydomain>
DocumentRoot /var/www/<mydomain>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Protocols h2 http/1.1
<If "%{HTTP_HOST} == '<mydomain>'">
Redirect permanent / https://<mydomain>/
</If>
</VirtualHost>
Apache status ->
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sun 2021-12-26 13:45:17 CET; 12min ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 12093 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Process: 12177 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
Main PID: 12097 (code=exited, status=0/SUCCESS)
dec 26 13:45:14 <>.stratoserver.net systemd[1]: Starting The Apache HTTP Server...
dec 26 13:45:14 <>.stratoserver.net systemd[1]: Started The Apache HTTP Server.
dec 26 13:45:17 <>.stratoserver.net apachectl[12179]: httpd (pid 12097?) not running
dec 26 13:45:17 <>.stratoserver.net systemd[1]: apache2.service: Succeeded.
It did however work for one moment, it only showed the default page even though it is disabled. And now it just refuses to run. Some help would be great, any extra info needed let me know.
Error log ->
[Sun Dec 26 13:45:14.394312 2021] [core:warn] [pid 12097:tid 140257795902528] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Dec 26 13:45:14.395297 2021] [mpm_event:notice] [pid 12097:tid 140257795902528] AH00489: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Dec 26 13:45:14.395309 2021] [core:notice] [pid 12097:tid 140257795902528] AH00094: Command line: '/usr/sbin/apache2'
[Sun Dec 26 13:45:14.397770 2021] [mpm_event:alert] [pid 12098:tid 140257795902528] (11)Resource temporarily unavailable: AH00480: apr_thread_create: unable to create worker thread
[Sun Dec 26 13:45:14.402620 2021] [mpm_event:alert] [pid 12099:tid 140257477809920] (11)Resource temporarily unavailable: AH03104: apr_thread_create: unable to create worker thread
[Sun Dec 26 13:45:16.396433 2021] [mpm_event:alert] [pid 12097:tid 140257795902528] AH02324: A resource shortage or other unrecoverable failure was encountered before any child process initialized successfully... httpd is exiting!
Ran configtest output -> Syntax OK
Could not find specifically httpd.conf, did however find a http2.conf consisting:
# mod_http2 doesn't work with mpm_prefork
<IfModule !mpm_prefork>
Protocols h2 h2c http/1.1
# # HTTP/2 push configuration
#
# H2Push on
#
# # Default Priority Rule
#
# H2PushPriority * After 16
#
# # More complex ruleset:
#
# H2PushPriority * after
# H2PushPriority text/css before
# H2PushPriority image/jpeg after 32
# H2PushPriority image/png after 32
# H2PushPriority application/javascript interleaved
#
# # Configure some stylesheet and script to be pushed by the webserver
#
# <FilesMatch "\.html$">
# Header add Link "</style.css>; rel=preload; as=style"
# Header add Link "</script.js>; rel=preload; as=script"
# </FilesMatch>
# Since mod_http2 doesn't support the mod_logio module (which provide the %O format),
# you may want to change your LogFormat directive as follow:
#
# LogFormat "%v:%p %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
# LogFormat "%h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined
# LogFormat "%h %l %u %t \"%r\" %>s %B" common
</IfModule>
And found this part in apache2.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>`
Also memory;
$ free -m
total used free shared buff/cache available
Mem: 4096 95 3701 3 298 3997
Swap: 0 0 0