]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/forum/Using_reverse_proxy__59___base_URL_is_http_instead_of_https/comment_5_674f56100c0682eba36cc5327fbdae4a._comment
git: Turn $git_dir into a stack
[git.ikiwiki.info.git] / doc / forum / Using_reverse_proxy__59___base_URL_is_http_instead_of_https / comment_5_674f56100c0682eba36cc5327fbdae4a._comment
1 [[!comment format=mdwn
2  username="https://www.google.com/accounts/o8/id?id=AItOawk6z7Jsfi_XWfzFJNZIjYUcjgrthg4aPUU"
3  nickname="Alejandro"
4  subject="Same Trick in Apache"
5  date="2014-09-10T18:58:24Z"
6  content="""
7 I got it working with Apache 2.4 and Virtual Hosts on both HTTP 1.1 and HTTPS (SNI). The procedure is somewhat analogous to the nginx procedure above. So here is my set-up in the hopes will help other avoid this pain.
9 ## Set-up
11     CLIENT <---- HTTPS ----> REVERSE PROXY <---- HTTP ----> IKIWIKI
14 ## The HTTP to HTTPS Redirect
16 To assure that all your HTTP requests are being redirected to HTTPS I chose to use mod_rewrite because simple Redirect does not pass query parameters. You will want an HTTP VHost that will redirect with something like the one below (notice the subtle ? before query string). **Note: This will NOT re-write ikiwiki's http:// URLs (base tag, etc.)**. For that I use a content filter like you will see below. This HTTP to HTTPS redirect is required though for both security and for the /foo/?updated URI form in this set-up.
18 <pre>
20 &lt;VirtualHost *:80&gt;
21     ServerName imass.name
22     RewriteEngine On
23     RewriteCond %{HTTPS} off
24     RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}?%{QUERY_STRING}
25     ErrorLog /var/log/imass.name-error.log
26     LogLevel warn
27     CustomLog /var/log/imass.name-access.log combined
28 &lt;/VirtualHost&gt;
30 </pre>
32 ## The SSL Virtual Host
34 This part is a bit more tricky. First I am using SNI as I don't care for non-SNI user agents. Second, you need to use a filter that replaces all http:// to https:// before the response is set. Note that this alone won't deal with ?update so you will need the HTTP to HTTPS set-up above anyway. Third, I use HTTP Auth so I don't know if this will work with your particular Auth set-up (although it should IMHO), YMMV:
36 <pre>
38 &lt;VirtualHost *:443&gt;
39     ServerName imass.name
40     ProxyHTMLEnable On
41     ProxyHTMLExtended On
42     SSLEngine on
43     SSLCertificateFile XXX
44     SSLCertificateKeyFile XXX
45     SSLCertificateChainFile XXX
46     SSLOptions +StdEnvVars
47     ProxyPreserveHost On
48     ProxyHTMLURLMap http:// https://
49     ProxyPass / http://192.168.101.101/
50     ProxyPassReverse / http://192.168.101.101/
51     LogLevel warn
52     ErrorLog /var/log/imass.name-ssl-error.log
53     TransferLog \"/var/log/imass.name-ssl-access.log\"
54     CustomLog \"/var/log/imass.name-ssl-request.log\" \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \\"%r\\" %b\"
55 &lt;/VirtualHost&gt;
57 </pre>
61 """]]