From 5c5cc401d0e83c1586fbc551f5112c792e82e540 Mon Sep 17 00:00:00 2001 From: Josh-Cena Date: Sat, 14 Aug 2021 12:19:20 +0800 Subject: [PATCH 1/4] Add self-host.md Signed-off-by: Josh-Cena --- docs/Self-host.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++ static/index.html | 3 +++ 2 files changed, 72 insertions(+) create mode 100644 docs/Self-host.md diff --git a/docs/Self-host.md b/docs/Self-host.md new file mode 100644 index 0000000..2ea5618 --- /dev/null +++ b/docs/Self-host.md @@ -0,0 +1,69 @@ +# Self-hosted HTTP servers + +We will serve the [static](../static) folder using different HTTP servers. + +## Apache + +### Default settings + +The Apache server has the following configuration in `sites-available`: + +```apache + + ServerName trailing-slash-guide-apache-default.sida-chen.com + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html/static + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + +``` + +**Deployment**: [trailing-slash-guide-apache-default.sida-chen.com](http://trailing-slash-guide-apache-default.sida-chen.com) + +| Url | Result | +| ------------------ | ----------- | +| /file | 💢 404 | +| /file/ | 💢 404 | +| /file.html | ✅ | +| /folder | ➡️ /folder/ | +| /folder/ | ✅ | +| /folder/index.html | ✅ | +| /both | ➡️ /both/ | +| /both/ | ✅ | +| /both.html | ✅ | +| /both/index.html | ✅ | + +### How do I... + +- ...make the `/file` path accessible? + A: Add the following to your configuration: + ```apache + RewriteEngine On + RewriteCond %{REQUEST_URI} !(\.[A-Za-z0-9]*$|/$) + RewriteRule ^(.*)$ $1.html + ``` + This appends the `.html` extension to any requests to routes without trailing slash or extension. Check out [trailing-slash-guide-apache-no-extension.sida-chen.com](http://trailing-slash-guide-apache-no-extension.sida-chen.com) for this configuration in action. + | Url | Result | + | ------------------ | ----------- | + | /file | ✅ | + | /file/ | 💢 404 | + | /file.html | ✅ | + | /folder | ➡️ /folder/ | + | /folder/ | ✅ | + | /folder/index.html | ✅ | + | /both | ➡️ /both/ | + | /both/ | ✅ | + | /both.html | ✅ | + | /both/index.html | ✅ | +- ...enforce a trailing slash policy? + A: +- ...make all routes accessible? + A: + +## Nginx + + + +## Vercel/serve + +This is a simple HTTP server run in Node.js. It has the same configuration options and implementation as [Vercel](./Hosting-Providers.md#Vercel), so read more about it there. diff --git a/static/index.html b/static/index.html index c0b6469..2607680 100644 --- a/static/index.html +++ b/static/index.html @@ -1,4 +1,7 @@ + + +