> 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="/files/sYkKIS9Rw3BpVfr6RgHw" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/cNMgLRVSFotqOcV8iY8n" 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
```
