As I was working on our new Alpha Program at Leka, I decided to use boarding by fastlane to set up a small server for people to onboard and get our app through TestFlight.

The deployment process is super easy, you just need to follow the steps described in the README. So after a couple of minutes I had a working on boarding website hosted on Heroku...

alpha-onboarding.herokuapp.com

For our future user, I wanted two websites:

Heroku has documentation for setting a custom domain but it involves modifying the DNS, which was not an option for me.

The best option I could see was to customize nginx to use proxy_pass to the Heroku app.

Easier said than done... We use proxy_pass extensively for our apps and blogs, but they usually reside on the same VM. So it's just a question of setting upstream like in the following example.

upstream myblog {
	server 127.0.0.1:2368;
}

server {
	listen 80;
	server_name myblog.me;

	location / {
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $http_host;
		proxy_set_header X-NginX-Proxy true;
		proxy_pass http://myblog;
		proxy_redirect off;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
	}
}

This solution doesn't work for Heroku app. After extensive research, this is what I came out with, and it works amazingly well.

server {
	listen 80;
	server_name my-alpha-program.com;

	root /var/www/my-alpha-program.com;

	# location of the information website
	location / {
		try_files $uri $uri/ $uri.html =404;
	}

	# location of the on boarding website
	location /onboarding/ {
		rewrite ^/onboarding/?(.*)$ /$1 break;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass https://my-alpha-program.herokuapp.com;
	}

	location /assets/ {
		rewrite ^(/.*) https://my-alpha-program.herokuapp.com/$uri;
	}
}

As you can see, there is also a location /assets/ directive. Without it ressources like images, css and js are not accessible through the proxy_pass and will give you 404 errors.

Hope these settings will be useful to other people who would like to choose the url they want for their boarding website.