Docusaurus Hosting
How to self host Docusaurus in an internal network?
Docusaurus can be self-hosted using the docusaurus serve
command. You can change the port and host by using the --port
and --host
options respectively [0]. For example:
npm run serve -- --build --port 80 --host 0.0.0.0
If your internal network uses Apache as a web server, you can leverage the mod_rewrite
module to configure URL routing for your Docusaurus v2 site. An example configuration using .htaccess
file is provided in [1]:
RewriteEngine On
RewriteCond %{HTTP_HOST} =example.com
What if i want to access is via www.example-docs.corp?
To access Docusaurus v2 via a custom domain like www.example-docs.corp
, you would need to configure your DNS settings to point to the IP address or hostname of the machine where Docusaurus is hosted. This can typically be done through your company's domain registrar or DNS provider. Once the DNS settings have propagated, you should be able to access your Docusaurus site using the custom domain.
For self-hosting, you can specify the host parameter when running docusaurus serve to bind the server to a specific hostname or IP address. For example, to bind to the IP address 192.168.0.10
and port 3000, you would run docusaurus serve --host 192.168.0.10 --port 3000
. Keep in mind that you may need to configure your local firewall to allow incoming traffic on the specified port.