A virtual hosting requires Apache2 as webserver (due to the need for .htaccess). Hence can't directly replace it with NginX.
Solution in brief:
Setup a Varnish as cache but Varnish does not support SSL
Hence we need to setup an NginX as reverse proxy to listen to port 443 and redirect the request to Varnish.
The last step was to setup http to https re-direction. This could not be done directly under ISPConfig 3 http-to-https switch because this Apache2-based setting will create an infinite loop. This is resolved by creating a redirect within Varnish via its configuration language VCL.
Solution step-by-step:
Source:
1. https://github.com/manoaratefy/ispconfig3-varnish
When performing the steps by following Source 1, also turn off any Apache2 http to https redirect under ISPConfig after re-sync the websites.
Then remove the default NginX vhost:
rm /etc/nginx/sites-enabled/default
Then perform the final steps as directed, i.e. restart the services:
systemctl restart apache2
systemctl restart varnish
systemctl restart nginx
2. https://gist.github.com/section-io-gists/2eb0f267a08734f92003f06d295af22a
In this step, we configure Varnish to direct http to https
Add the code highlighted in red in the corresponding block:
sub vcl_recv {
if (req.http.X-Forwarded-Proto !~ "https") {
return (synth(850, "Moved Permanently"));
}
}
Add the following 2 new blocks at the end of the config file:
sub vcl_synth {
if(resp.status == 850) {
set resp.http.Location = "https://" + req.http.host + req.url;
set resp.status = 301;
return(deliver);
}
}
sub vcl_hash {
hash_data(req.http.X-Forwarded-Proto);
}
Then restart Varnish:
systemctl restart varnish
Solution in brief:
Setup a Varnish as cache but Varnish does not support SSL
Hence we need to setup an NginX as reverse proxy to listen to port 443 and redirect the request to Varnish.
The last step was to setup http to https re-direction. This could not be done directly under ISPConfig 3 http-to-https switch because this Apache2-based setting will create an infinite loop. This is resolved by creating a redirect within Varnish via its configuration language VCL.
Solution step-by-step:
Source:
1. https://github.com/manoaratefy/ispconfig3-varnish
When performing the steps by following Source 1, also turn off any Apache2 http to https redirect under ISPConfig after re-sync the websites.
Then remove the default NginX vhost:
rm /etc/nginx/sites-enabled/default
Then perform the final steps as directed, i.e. restart the services:
systemctl restart apache2
systemctl restart varnish
systemctl restart nginx
2. https://gist.github.com/section-io-gists/2eb0f267a08734f92003f06d295af22a
In this step, we configure Varnish to direct http to https
Add the code highlighted in red in the corresponding block:
sub vcl_recv {
if (req.http.X-Forwarded-Proto !~ "https") {
return (synth(850, "Moved Permanently"));
}
}
Add the following 2 new blocks at the end of the config file:
sub vcl_synth {
if(resp.status == 850) {
set resp.http.Location = "https://" + req.http.host + req.url;
set resp.status = 301;
return(deliver);
}
}
sub vcl_hash {
hash_data(req.http.X-Forwarded-Proto);
}
Then restart Varnish:
systemctl restart varnish
Comments
Post a Comment