How to enable Apache SSL module in Ubuntu

Apache web server

To enable the Apache SSL module in Ubuntu, follow these steps Update apt package cache apt update Install Apache SSL module apt install libapache2-mod-ssl Enable the SSL module a2enmod ssl Example # a2enmod ssl Considering dependency setenvif for ssl: Module setenvif already enabled Considering dependency mime for ssl: Module mime already enabled Considering dependency socache_shmcb … Read more

How to configure Security Headers in Apache

Apache web server

Enable HSTS Header set Strict-Transport-Security “max-age=31536000; includeSubDomains; preload” Enable X-Frame-Options Header always append X-Frame-Options SAMEORIGIN Enable X-XSS-Protection Header set X-XSS-Protection “1; mode=block” Enable X-Content-Type-Options Header always set X-Content-Type-Options “nosniff” Enable Referrer-Policy Header always set Referrer-Policy “strict-origin” Enable Content Security Policy (CSP) Header always set Content-Security-Policy “default-src ‘self’; font-src *;img-src * data:; script-src *; style-src *;” … Read more

Apache 414 Request-URI Too Long

Apache web server

On an Apache server, when accessing a long URL, got 414 Request-URI Too Long The error is because the URL is too long, this may be a bug with the web applications. If you pass so much data, you should consider using the HTTP POST method instead of GET request. To fix this error, edit … Read more

How to install Apache from source code

Apache web server

To install the latest version of Apache Web Server from source code, go to the apache website, download the latest source code .tar.gz file. https://httpd.apache.org/download.cgi At the time of writing this, the latest version was Apache HTTP Server 2.4.52. cd /usr/local/src wget –no-check-certificate https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz tar xvf httpd-2.4.52.tar.gz cd /usr/local/src/httpd-2.4.52 ./configure –prefix=/usr/local/apache –enable-proxy –enable-proxy-connect –enable-proxy-fcgi –enable-remoteip … Read more

Apache 413 Request Entity Too Large

Apache web server

On a CentOS server, when uploading a 100 MB video file in WordPress media manager, I got the following error message Request Entity Too Large The requested resource /wp-admin/async-upload.php does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit. The server had mod_security installed. … Read more

How to debug Apache VirtualHost not working

On an Apache webserver running in Ubuntu, I added a VirtualHost entry for a domain name. But instead of showing the page, it shows the website from the default Apache VirtualHost (000-default.conf). At first, I was thinking it is because Apache was somehow not able to handle Named Virtual Hosts. So I created another domain … Read more

Apache Location

To only allow requests from a specific IP to a location, use Require ip 59.92.71.53 51.38.246.115 Require ip 59.92.71.53 51.38.246.115 Add custom headers based on location Require ip 59.92.71.53 51.38.246.115 Header edit Location ^/browse /internal/stream/browse AddOutputFilterByType INFLATE;SUBSTITUTE;DEFLATE text/html text/plain text/xml Substitute “s#\”/(fields|browse|machine|entries)#\”/internal/stream/$1#i”

Apache Proxy

To proxy requests in Apache For proxying HTTPS traffic, use If remote SSL is invalid, you can disable SSL verification You need to enable following apache modules for proxy to work The ProxyPreserveHost directive in Apache’s configuration is used in the context of a reverse proxy setup. When this directive is set to On, it … Read more