Skip to content

Instantly share code, notes, and snippets.

@RienNeVaPlus
Last active June 11, 2021 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RienNeVaPlus/c830d443bb25bb94eaa8f751c1bd63dd to your computer and use it in GitHub Desktop.
Save RienNeVaPlus/c830d443bb25bb94eaa8f751c1bd63dd to your computer and use it in GitHub Desktop.
How-to configure Mail-in-a-Box (MIAB) nginx to work with StencilJS or any other JavaScript router that requires a single entry point
location / {
index index.html;
try_files $uri $uri/ /index.html;
}
@RienNeVaPlus
Copy link
Author

RienNeVaPlus commented Mar 8, 2020

How-to configure mailinabox's nginx to work with StencilJS

...or any other JavaScript router that requires a single entry point (index.html)

Mailinabox's default nginx config depends on file name extensions. However, nowadays most applications require a single entry point (index.html) for all routes to work properly. Luckily there is an unsupported feature that let's you create custom nginx configs for your mailinabox hosts.

Setup

  • Create a Static Web Hosting directory for your domain in the MIAB admin pannel, for example /home/user-data/www/example.com/
  • Copy the build directory of your StencilJS project into the same folder
  • Create a custom nginx config inside the mailinabox www directory, for example /home/user-data/www/example.com.conf
  • Copy the nginx configuration from this gist into the file and save
  • Run /root/mailinabox/tools/web_update

All routes should now redirect to your index.html and you're good to go.

@RienNeVaPlus
Copy link
Author

Note: it's required to rename the conf file after editing it, otherwise the changes won't get picked up by the web_update script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment