> For the complete documentation index, see [llms.txt](https://dev-notes.vinguyen.blog/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-notes.vinguyen.blog/notes/deployment-and-operation/ngnix/download-file-from-server-via-nginx-docker.md).

# Download file from server via nginx docker

Crete struct folder like this:&#x20;

<figure><img src="https://4097721540-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyERTXkEYvKhAFtQ6fA74%2Fuploads%2FUmNdOG7OZKiZkrWTZmUD%2FCleanShot%202024-05-16%20at%2015.45.08%402x.png?alt=media&amp;token=5ce5ae5c-1a4c-4307-9e9b-5f246611dc29" alt=""><figcaption></figcaption></figure>

1. Put all your download files into **files**  folder

<figure><img src="https://4097721540-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyERTXkEYvKhAFtQ6fA74%2Fuploads%2FRDxnp9vok1JYyv0bAWUl%2FCleanShot%202024-05-16%20at%2015.42.55%402x.png?alt=media&amp;token=645b5eea-2fdd-4c0a-9a68-3599cd7c7702" alt=""><figcaption></figcaption></figure>

1. Create file conf/dowload.conf

```
server {
  listen 80;
  server_name _;
  # serve the static files on port 80
  location /downloads/ {
    alias /files/;
  }
}
```

3. Create docker compose file:

```
version: '3'

services:
  nginx:
    image: nginx:latest
    volumes:
      - ./files:/files
      - ./conf:/etc/nginx/conf.d
    ports:
      - "8080:80"
```

4. Start docker container

```
docker compose up -d
```

5. Download files

```
curl http://your_ip:8080/downloads/files.sql.gz
```

6. Shutdown container after download

```
docker compose down
```
