# I’M SO CLOSE! (deployment)

**URL:** <https://discuss.streamlit.io/t/i-m-so-close-deployment/14007>\
**Category:** Deployment\
**Tags:** nginx, docker, https\
**Created:** [June 15, 2021, 9:20am UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007 "2021-06-15T09:20:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [June 15, 2021, 9:20am UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/1 "2021-06-15T09:20:18Z")

</div>

I’m so proud to be as close as I am to have a stable and secure web app. I am a student studying Finance and Economics so I’m not well versed in full stack development. I found out about streamlit about a month ago and fell in LOVE. I’ll keep this short.

I’m using nginx in a docker container as a reverse proxy to my streamlit app in another container. I’m hosting the server through linode and setup a rDNS through their Domain manager. Once I get letsencrypt working I will post all my code and make a few videos.

[http://www.joeysapps.com](http://www.joeysapps.com)

Ps. If the link isn’t working then I’m probably working on it or I forgot to pay my bills

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [June 16, 2021, 12:16am UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/2 "2021-06-16T00:16:11Z")

</div>

I got it working! [https://joeysapps.com](https://joeysapps.com)  
I will write out the workflow soon.

---

<div class="post-metadata">

**Author:** ![andfanilo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/andfanilo/32/1040_2.png) [@andfanilo](https://discuss.streamlit.io/u/andfanilo)\
**Post date:** [June 16, 2021, 9:35am UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/3 "2021-06-16T09:35:16Z")

</div>

Hello @joeychrys, nice to see you got it working, I’ll be waiting for your breakdown post 🙂 !

(Firefox is angry at me for trusting your letsencrypt certificate but it is working indeed 😉 )

Fanilo 🎈

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [June 16, 2021, 10:33am UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/4 "2021-06-16T10:33:03Z")

</div>

I will create a breakdown soon! Yeah I think the problem is that I don’t have [www.joeysapps.com](http://www.joeysapps.com) setup with a cert. I only have [joeysapps.com](http://joeysapps.com) setup. Firefox gives me the same problem ☹

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 4:00pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/5 "2021-11-28T16:00:17Z")

</div>

Hi, I went to your app (congratulations btw, I’m very excited to have mine up and running as well), and found your code. I was wondering how you got it to work using `https`.

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:02pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/6 "2021-11-28T18:02:18Z")

</div>

Hey there. I would love to help. I’ve been procrastinating on creating a full tutorial on how to get https working. Are you using Docker with streamlit and nginx?

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 6:06pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/7 "2021-11-28T18:06:15Z")

</div>

Hi! yes sir. But with all honesty, although I have a fair understanding on what a single Docker container is doing and how you can deploy it, having two containers is something I attempted for the first time on my own, and I did use docker-compose to get things up and running. [Here](http://sexest.cyi.ac.cy/) is my app btw.

My understanding is that nginx is something like a proxy that does the https trick but how?

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:15pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/8 "2021-11-28T18:15:54Z")

</div>

So Nginx is a load balancer/web-server. Requests are first sent to nginx and then those requests are served to streamlit via a reverse proxy. Nginx handles the “three way handshake” that happens when a user makes a request to your server. I use letsencrpyt for the SSL certs that are needed for https. I then have a certbot container which handles auto renewal of the SSL certs. I followed this [guide](https://pentacent.medium.com/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71) on how to get the certs running on the server.

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:23pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/9 "2021-11-28T18:23:42Z")

</div>

Here is my current app.conf that is being used to configure nginx

```auto
server {

	listen 80;
	server_name example.com;

	location / {
		return 301 https://$host$request_uri;
	}

	location /.well-known/acme-challenge/ {
		root /var/www/certbot;
	}

}
# I use upstream but its not needed.
# If you want to use it you can just change 
# "upstream {name_of_streamlit_container}"
upstream streamlit_app {
    server streamlit_app:8501;
}

server {

	listen 443 ssl;
	server_name example.com;

	ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
	include /etc/letsencrypt/options-ssl-nginx.conf;
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

	# streamlit config
	location / {
		proxy_pass http://streamlit_app/;
	}

	location ^~ /static {
		proxy_pass http://streamlit_app/static/;
	}

	location ^~ /healthz {
		proxy_pass http://streamlit_app/healthz;
	}

	location ^~ /vendor {
		proxy_pass http://streamlit_app/vendor;
	}

	location /stream {
		proxy_pass http://streamlit_app/stream;
		proxy_http_version 1.1;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $host;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 86400;
	}

}

```

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:27pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/10 "2021-11-28T18:27:50Z")

</div>

Here is my docker-compose.yml

```auto
version: '3.8'

services:
  streamlit:
    container_name: streamlit_app
    restart: always
    expose:
      - "8501"
    build: ./streamlit_app
    command: streamlit run app_6.py

  nginx:
    restart: always
    image: nginx:1.15-alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./data/nginx:/etc/nginx/conf.d
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

  certbot:
    container_name: certbot
    image: certbot/certbot
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

```

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 6:29pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/11 "2021-11-28T18:29:10Z")

</div>

Wow! Thank you so much. I’ll try it out and let you know how it worked out 🙂

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:35pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/12 "2021-11-28T18:35:53Z")

</div>

Alright sounds good. I’ve helped a few people get this working via the streamlit discord. I’m always happy to ssh into a sever and get this working. I know how confusing this can be (it took me months to understand all this) as you just want to be able to share a streamlit app and not worry about full stack development. If you need more hands on help, just hit me up through discord. My username is yoyojoe#5510.

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 6:41pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/13 "2021-11-28T18:41:20Z")

</div>

> [@joeychrys](#):
>
> yoyojoe#5510

Honestly, I was shocked I was able to put a web app of my own up and running in about a month. But now I want it to be perfect. And I spent hours searching online for this so thank you again!

P.S: I sent you a friend request on discord!

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 6:44pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/14 "2021-11-28T18:44:58Z")

</div>

I know the feeling oh too well. I’m in school right now so I don’t have as much time as I would like but I’m in the process of developing a template that someone can just clone and have everything they need for certs/nginx/streamlit. I’m trying to use cookiecutter for it.

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 10:52pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/15 "2021-11-28T22:52:26Z")

</div>

But you are defining a service `- web` which is not defined in your compose file.

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 11:05pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/16 "2021-11-28T23:05:48Z")

</div>

Oh my bad. So I forgot to take that out. Web is a container that has a django application in it. I’ll take that out real quick. You can just remove that.

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 11:07pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/17 "2021-11-28T23:07:08Z")

</div>

I did, but I still have no luck setting this up. But I would be completely hopeless without your hints so no worries 🙂

---

<div class="post-metadata">

**Author:** ![joeychrys](https://avatars.discourse-cdn.com/v4/letter/j/aca169/32.png) [@joeychrys](https://discuss.streamlit.io/u/joeychrys)\
**Post date:** [November 28, 2021, 11:10pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/18 "2021-11-28T23:10:15Z")

</div>

Were you able to get dummy SSL certificates with letsencrypt? And who is your cloud provider(ex: Linode, AWS)?

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 11:14pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/19 "2021-11-28T23:14:11Z")

</div>

I think I got the certificates yes. I’m not running on a cloud provider. I have a web server (Virtual Machine). And I’m out of my depth in general ☹

---

<div class="post-metadata">

**Author:** ![cconsta1](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/cconsta1/32/74935_2.png) [@cconsta1](https://discuss.streamlit.io/u/cconsta1)\
**Post date:** [November 28, 2021, 11:17pm UTC](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007/20 "2021-11-28T23:17:47Z")

</div>

The containers seem to be running fine though. Anyway, I’ll be back to this tomorrow morning (its past midnight here). And I’ll mention what I did for others 🙂

[Next page](https://discuss.streamlit.io/t/i-m-so-close-deployment/14007.md?page=2)
