Apache http server (httpd)
This section describes how to use apache (https://httpd.apache.org/) as a web server.
To use HTTPD, it needs to be installed in the system and the daemon should be running with the appropriate site configurations setup.
Installation
The official installation instructions can be found at https://httpd.apache.org/docs/2.4/install.html
The recommended method of installation is to use the package manager provided by the Operating System (apt-get, yum, etc.).
RedHat:
yum install httpd
Ubuntu:
apt install apache2
Configurations
Once installed, the httpd configuration needs to be created to proxy the web server components as described in https://httpd.apache.org/docs/2.4/vhosts/examples.html and https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass
Configuration example for CentOS
Here is an example httpd configuration that sets up the Web Application Server:
-
Create the file:
/etc/httpd/sites-available/corridorapp.confwith below configs<VirtualHost *:80> ServerName www.corridorapp.com ServerAlias corridorapp ProxyPass / http://localhost:5002/ ProxyPassReverse / http://localhost:5002/ ErrorLog /var/www/corridorapp/log/error.log CustomLog /var/www/corridorapp/log/requests.log combined </VirtualHost> -
Create symlink to the above file as
/etc/httpd/sites-enabled/corridorapp.confusing the command:- This is done to control the configs available versus the subset of those enabled
-
Add below text to
/etc/httpd/conf/httpd.conf:IncludeOptional sites-enabled/*.conf
Configuration example for CentOS (SSL based)
To setup a secure connection, update the /etc/httpd/sites-available/corridorapp.conf file as below:
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /certs/app.crt
SSLCertificateKeyFile /certs/app.key
SSLCertificateChainFile /certs/ca.crt
ServerName www.corridorapp.com
ServerAlias corridorapp
ProxyPass / http://localhost:5002/
ProxyPassReverse / http://localhost:5002/
ErrorLog /var/www/corridorapp/log/error.log
CustomLog /var/www/corridorapp/log/requests.log combined
</VirtualHost>
Note
If the httpd is not listening on port 80 (443 for SSL) - but listens on another port, the
corresponding port has to be added along with VirtualHost keyword and the Listen param's value has to be appropriately updated in /etc/httpd/conf/httpd.conf (/etc/httpd/conf.d/ssl.conf for SSL).
Note: Permission issues
In case of permission issues, ensure user permissions and SELinux is set up correctly.