Last active
July 22, 2021 11:00
-
-
Save MahdiBM/ddb9c6ccbf26cf5403e6baef78530e35 to your computer and use it in GitHub Desktop.
Setting up routing for a DocC Archive (`.doccarchive`) in Nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the whole file once, if you're going to use it. There are a few things you need to change. | |
# Disclaimer: | |
# I'm using a very similar code myself, but i'm not a Nginx expert, so use this at your own risk. | |
server { | |
server_name YOURDOMAIN.COM WWW.YOURDOMAIN.COM; | |
# Example: `server_name oauthbm.mahdibm.com www.oauthbm.mahdibm.com;` | |
root /path/to/NAME_OF_ARCHIVE.doccarchive; | |
# Example: `home/ubuntu/OAuthBM/OAuthBM.doccarchive;` | |
# The code below is required, as per what Apple says in th WWDC video `Host and automate your DocC documentation`. Watch that for more. | |
location /tutorials { | |
try_files $uri /index.html; | |
} | |
# The code below is required, as per what Apple says in th WWDC video `Host and automate your DocC documentation`. Watch that for more. | |
location /documentation { | |
try_files $uri /index.html; | |
} | |
# The code below is NOT required. You can remove it. | |
# DocC doesn't have a starting page, so _without_ this code, if you for example do `oauthbm.mahdibm.com` you'll see a `NOT FOUND` page. | |
# This code will instead redirect people to the `tutorials` section of your DocC documentation. | |
location = / { | |
return 302 /tutorials/NAME_OF_PACKAGE; | |
# Example: `return 302 /tutorials/oauthbm;` | |
} | |
# NOTE: | |
# `/tutorials` and `/documentation` endpoints themselves will just show a `NOT FOUND` page. | |
# Instead you need to do `/tutorials/NAME_OF_PACKAGE` and `/documentation/NAME_OF_PACKAGE` (e.g. in my case `/tutorials/oauthbm`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment