# Deploying nginx in docker with Streamlit and Fastapi

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068%3E%5C
**Category:** Spaces\
**Created:** [July 2, 2024, 4:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068 "2024-07-02T04:34:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kidcoconut](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kidcoconut/32/28896_2.png) [@kidcoconut](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkidcoconut)%5C
**Post date:** [July 2, 2024, 4:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068%2F1 "2024-07-02T04:34:42Z")

</div>

Hi there,  
I am attempting to create a stable and reusable huggingface docker space for hosting streamlit and fastapi through nginx.

I want to expose streamlit at the root (/) and fastapi endpoint at (/api/)

I have the docker container running locally and working as expected.

The problem is that on Huggingface, the streamlit landing page (/) displays ok, but an attempt to land on fastapi (/api/) yields a 404 error.

I have tried to enable logs with no luck.

Any help appreciated.

The (public) project is located at:

> **[spcDkr nginx template - a Hugging Face Space by kidcoconut](https://huggingface.co/spaces/kidcoconut/dkr_nginx_templ)**
>
> Discover amazing ML apps made by the community

---

<div class="post-metadata">

**Author:** ![kidcoconut](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kidcoconut/32/28896_2.png) [@kidcoconut](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkidcoconut)%5C
**Post date:** [July 7, 2024, 5:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068%2F2 "2024-07-07T05:01:06Z")

</div>

Update:

ok. I am at the end of my tether with this.

I have added logging for nginx, and for fastapi in an attempt to trace online what is going on. No change. The docker container is running fine locally, but nginx is not reverse proxying properly in huggingface.

I was able to select the ‘Run in Docker’ option. This provided me the ref link required to pull my huggingface image locally and run on docker desktop.

It ran just fine locally. This tells me that it is not a rebuild issue. Something is different from an env config between the docker container host locally versus in huggingface.

Any assistance appreciated.

---

<div class="post-metadata">

**Author:** ![kidcoconut](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kidcoconut/32/28896_2.png) [@kidcoconut](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkidcoconut)%5C
**Post date:** [July 12, 2024, 4:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068%2F3 "2024-07-12T04:01:53Z")

</div>

Solved.

The root problem is that documentation is weak.

All samples/examples are illustrated through code or through the hub UI.

None explicitly state that in order to see your docker container run in ‘prod’, you need to access your endpoints through a different domain.

https://{username}-{space name with hyphens instead of spaces or underscores}.hf.space/{endpoint}/

In my case, for my streamlit endpoint  
[https://kidcoconut-dkr-nginx-templ.hf.space/web/](https://kidcoconut-dkr-nginx-templ.hf.space/web/)

---

<div class="post-metadata">

**Author:** ![ronnys](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@ronnys](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fronnys)%5C
**Post date:** [July 19, 2024, 9:17am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdeploying-nginx-in-docker-with-streamlit-and-fastapi%2F95068%2F4 "2024-07-19T09:17:57Z")

</div>

Hello it is weaked too
