Serving Docusaurus from Nginx with baseUrl #10827
Unanswered
GuyShalomCyberRidge
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! 😄
I'll start by explaining my final goal and then my issue and what I tried doing.
The goal:
I have my main app served with Nginx from
/
, and I'm trying to serve my Docusaurus app from subpath/documentation
.To try and achieve that I set
baseUrl: '/documentation/'
. I ran a test withnpm run serve
and like I expected, the app was served fromhttp://hostname/documentation/
and was working as intended. 👌The problem:
My problems started when I tried to serve the docs' static files with Nginx.
When configuring
location /documentation/
to serve the static files, I get an error:rewrite or internal redirection cycle while internally redirecting to "/documentation/index.html"
.I also tried serving
/index.html
instead of/documentation/index.html
like so:try_files $uri $uri/ /index.html;
but that just resulted in a 403 error code.I also tried serving the files in a separate Nginx server with no other locations, and I still got the same results 😒.
There is no mention in the Docusaurus docs of how to use baseUrl with Nginx as "The only responsibility of Docusaurus is to build your site and emit static files in build. It is now up to you to choose how to host those static files." written as a note here
Still, I'm wondering if there is a "correct" way of doing this, as I can't find anything online so maybe I'm completely off with my approach 🤷♂️.
Any help will be very very appreciated! 🙏🙏
Environment:
*If anything else might help please let me know!
Docusaurus version - 3.4.0
Nginx version - nginx/1.27.3
Everything is Dockerized (idk if that makes a difference)
docusaurus.config.js -
nginx.conf -
Beta Was this translation helpful? Give feedback.
All reactions