Apache HTTP Server: Difference between revisions

From David's Wiki
(Created page with " ==Compression== ==HTTPS Redirect== <pre> <VirtualHost *:80> ServerName my_server.com ServerSignature Off RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule .*...")
 
Line 16: Line 16:


==Proxying==
==Proxying==
[https://httpd.apache.org/docs/current/mod/mod_proxy.html mod_proxy documentation]<br>
[https://httpd.apache.org/docs//mod/mod_proxy_wstunnel.html mod_proxy_wstunnel documentation]<br>
General proxying to another server.<br>
General proxying to another server.<br>
Note that this can be another service on the same machine (localhost), same network, or another network entirely.<br>
Note that this can be another service on the same machine (localhost), same network, or another network entirely.<br>

Revision as of 21:53, 2 March 2020

Compression

HTTPS Redirect

<VirtualHost *:80>
  ServerName my_server.com
  ServerSignature Off

  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Proxying

mod_proxy documentation
mod_proxy_wstunnel documentation
General proxying to another server.
Note that this can be another service on the same machine (localhost), same network, or another network entirely.
This can be useful if you have a some entry point which handles HTTPS for another service on the same PC which does not handle HTTPS.

Requirements
  • mod_proxy
  • mod_proxy_wstunnel for websockets
  ProxyPreserveHost On
  ProxyRequests Off
  ProxyPass / http://192.168.1.99:80/
  ProxyPassReverse / http://192.168.1.99:80/

  # Proxy websockets
  ProxyPass "/ws2/"  "ws://echo.websocket.org/"
  ProxyPass "/wss2/" "wss://echo.websocket.org/"