Skip to content

Commit

Permalink
Merge pull request #437 from jhj0517/feature/deploy-w-domain
Browse files Browse the repository at this point in the history
Add nginx setup for backend
  • Loading branch information
jhj0517 authored Dec 25, 2024
2 parents 6abf188 + 093ee9f commit ad418ca
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,36 @@ pip install -r backend/requirements-backend.txt
uvicorn backend.main:app --host 0.0.0.0 --port 8000
```

### Deploy with your domain name
You can deploy the server with your domain name by setting up a reverse proxy with Nginx.

1. Install Nginx if you don't already have it.
- Linux : https://nginx.org/en/docs/install.html
- Windows : https://nginx.org/en/docs/windows.html

2. Edit [`nginx.conf`](https://github.com/jhj0517/Whisper-WebUI/blob/master/backend/nginx/nginx.conf) for your domain name.
https://github.com/jhj0517/Whisper-WebUI/blob/895cafe400944396ad8be5b1cc793b54fecc8bbe/backend/nginx/nginx.conf#L12

3. Add an A type record of your public IPv4 address in your domain provider. (you can get it by searching "What is my IP" in Google)

4. Open a terminal and go to the location of [`nginx.conf`](https://github.com/jhj0517/Whisper-WebUI/blob/master/backend/nginx/nginx.conf), then start the nginx server, so that you can manage nginx-related logs there.
```shell
cd backend/nginx
nginx -c "/path/to/Whisper-WebUI/backend/nginx/nginx.conf"
```

5. Open another terminal in the root project location `/Whisper-WebUI`, and deploy the app with `uvicorn` or whatever. Now the app will be available at your domain.
```shell
uvicorn backend.main:app --host 0.0.0.0 --port 8000
```

6. When you turn off nginx, you can use `nginx -s stop`.
```shell
cd backend/nginx
nginx -s stop -c "/path/to/Whisper-WebUI/backend/nginx/nginx.conf"
```


## Configuration
You can set some server configurations in [config.yaml](https://github.com/jhj0517/Whisper-WebUI/blob/master/backend/configs/config.yaml).
<br>For example, initial model size for Whisper or the cleanup frequency and TTL for cached files.
Expand Down
Empty file.
23 changes: 23 additions & 0 deletions backend/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
client_max_body_size 4G;

server_name your-own-domain-name.com;

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}

Empty file.

0 comments on commit ad418ca

Please sign in to comment.