Skip to content

Instantly share code, notes, and snippets.

@etienne-dldc
Last active January 27, 2019 22:58
Show Gist options
  • Save etienne-dldc/c29197445ee6b40ad9d7f42f02241e9b to your computer and use it in GitHub Desktop.
Save etienne-dldc/c29197445ee6b40ad9d7f42f02241e9b to your computer and use it in GitHub Desktop.
CapRover redirect non-www to www
# redirect non www
<%
if (s.publicDomain.match(/^(?!(www\.)).+$/)) {
%>
server {
<%
if (!s.forceSsl) {
%>
listen 80;
<%
}
if (s.hasSsl) {
%>
listen 443 ssl;
ssl_certificate <%-s.crtPath%>;
ssl_certificate_key <%-s.keyPath%>;
<%
}
%>
server_name <%-s.publicDomain%>;
return 302 https://www.$http_host$request_uri$is_args$query_string;
}
<%
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment