Oracle Linux/HTTP Reverse Proxy
From r00tedvw.com wiki
(Difference between revisions)
(Created page with "=Overview= This was done on a CentOS 6.9 x64 system. =Install Packages= <nowiki>~$ sudo yum update -y ~$ sudo yum install httpd openssh-server -y</nowiki> =Configure SSH= ...") |
|||
Line 28: | Line 28: | ||
Restart httpd for any changes to be implemented | Restart httpd for any changes to be implemented | ||
<nowiki>~$ sudo service httpd restart</nowiki> | <nowiki>~$ sudo service httpd restart</nowiki> | ||
+ | ==Conf== | ||
+ | Next is to configure the Conf file for the reverse proxy: | ||
+ | <nowiki>$~ sudo vim /etc/httpd/conf.d/website.conf | ||
+ | # HTTP | ||
+ | <VirtualHost *:80> | ||
+ | ServerName website.com | ||
+ | |||
+ | #Logging | ||
+ | LogLevel warn | ||
+ | ErrorLog /var/log/httpd/website.com-error_log | ||
+ | CustomLog /var/log/httpd/website.com-access_log combined | ||
+ | |||
+ | #Redirect any HTTP request to HTTPS | ||
+ | RewriteEngine On | ||
+ | RewriteCond %{HTTPS} off | ||
+ | RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] | ||
+ | |||
+ | </VirtualHost> | ||
+ | |||
+ | # HTTPS | ||
+ | <VirtualHost *:443> | ||
+ | ServerName website.com | ||
+ | |||
+ | #Logging | ||
+ | ErrorLog /var/log/httpd/website.com-error_log | ||
+ | CustomLog /var/log/httpd/website.com-access_log combined | ||
+ | |||
+ | #Reverse Proxy Configuration | ||
+ | ProxyPreserveHost On | ||
+ | |||
+ | ProxyPass / https://redirected.site.com:8081/ | ||
+ | ProxyPassReverse / https://redirected.site.com:8081/ | ||
+ | |||
+ | #SSL | ||
+ | #SSLEngine On | ||
+ | #SSLCertificateFile | ||
+ | #SSLCertificateKeyFile | ||
+ | #SSLCertificateChainFile | ||
+ | |||
+ | </VirtualHost></nowiki> |
Revision as of 22:51, 4 February 2018
Contents |
Overview
This was done on a CentOS 6.9 x64 system.
Install Packages
~$ sudo yum update -y ~$ sudo yum install httpd openssh-server -y
Configure SSH
Configure HTTPD
Modules
Start by checking what modules are installed.
~$ sudo httpd -M Loaded Modules: core_module (static) mpm_prefork_module (static) http_module (static) so_module (static)....
Make sure that you see the following:
rewrite_module (shared) proxy_module (shared) proxy_http_module (shared)
If they are not listed, you can enable them by uncommenting or adding them to the httpd.conf
file.
~$sudo vim /etc/httpd/conf/httpd.conf LoadModule rewrite_module modules/mod_rewrite.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so
Restart httpd for any changes to be implemented
~$ sudo service httpd restart
Conf
Next is to configure the Conf file for the reverse proxy:
$~ sudo vim /etc/httpd/conf.d/website.conf # HTTP <VirtualHost *:80> ServerName website.com #Logging LogLevel warn ErrorLog /var/log/httpd/website.com-error_log CustomLog /var/log/httpd/website.com-access_log combined #Redirect any HTTP request to HTTPS RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] </VirtualHost> # HTTPS <VirtualHost *:443> ServerName website.com #Logging ErrorLog /var/log/httpd/website.com-error_log CustomLog /var/log/httpd/website.com-access_log combined #Reverse Proxy Configuration ProxyPreserveHost On ProxyPass / https://redirected.site.com:8081/ ProxyPassReverse / https://redirected.site.com:8081/ #SSL #SSLEngine On #SSLCertificateFile #SSLCertificateKeyFile #SSLCertificateChainFile </VirtualHost>