Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nginx setup for backend #437

Merged
merged 9 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading