0

My current setup is nginx for a specific domain, which redirects all requests to https. But I have several subdomains which point directly to Google for Apps services (email, calendar, drive). These cannot be https because Google of course does not have a certificate for those. My end-goal is to have a HSTS header which has an includeSubdomains part for the main-domain.

To achieve this: Instead of having a CNAME of these subdomains point to ghs.google.com (email.example.com, calender.example.com, drive.example.com), which is the recommended option. I want to point them to my own server and redirect to the specific (but personalised) urls:

Question 1: Do you recommend against this? Any other possibilities?

However, it seems the recommended way to redirect a domain in nginx, is to have a separate server-block for each domain, if you want to have them point to a different url. But those ssl-server blocks are quite large even for a simple redirect:

server {

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name email.example.com;

    access_log /var/log/nginx/ghs.example.com/access.log;
    error_log  /var/log/nginx/ghs.example.com/error.log;

    ssl_certificate      /etc/letsencrypt/live/ghs.example.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/ghs.example.com/privkey.pem;

    gzip off;
    add_header Strict-Transport-Security "max-age=15811200 includeSubDomains";

    include server.d/letsencrypt.conf;

    return 302 https://mail.google.com/a/example.com;
}

Repeated 3 times.

I would much rather have this bock have server_name email.example.com calendar.example.com drive.example.com; and a redirect which separates them to their specific urls. But the nginx docs always quite explicitly recommends against this. And says I should use separate server blocks.

Question 2: Which options do I use? Is there another option to reduce the size of the duplicate configurations?

2
  • I suspect if you do it the standard way with the ghs subdomain Google will redirect to a new URL that provides https services. I don't see any point in what you're doing.
    – Tim
    Sep 25, 2016 at 18:19
  • Because I cannot run an HSTS header w/ includeSubDomains on my main domain because the redirect from Google has to be done over plain HTTP (because they don't have a cert for my subdomains). Yes the Google services are HTTPS, but my main domain isn't fully protected and I cannot preload the domain.
    – ontrack
    Sep 25, 2016 at 21:02

0

You must log in to answer this question.

Browse other questions tagged .