- Introduce a new `nginx-remote-dev` service in `docker-compose.yaml` for remote development environments, allowing Nginx to proxy requests to the host machine's frontend and backend services. - Create a new Nginx configuration file `ai-video.remote-dev.conf` tailored for remote setups, ensuring proper handling of WebSocket and API requests. - Update `README.md` to include detailed instructions for setting up remote development with Nginx, including certificate generation and service initialization. - Enhance the `setup-certs.sh` script to support additional hostnames for certificate signing, improving flexibility for remote access. - Revise documentation to clarify the development paths and requirements for local and remote environments.
84 lines
2.5 KiB
Plaintext
84 lines
2.5 KiB
Plaintext
# AI Video Assistant —— 远程开发机用 nginx 反代
|
|
#
|
|
# 适用场景:
|
|
# nginx 跑在 Docker 容器里;
|
|
# Next dev 和 uvicorn 跑在 Docker 宿主机上。
|
|
#
|
|
# 容器内不能用 127.0.0.1 访问宿主机进程,所以这里使用 host.docker.internal。
|
|
# 启动容器时需要加:
|
|
# --add-host=host.docker.internal:host-gateway
|
|
# 或使用 docker-compose.yaml 里的 nginx-remote-dev profile。
|
|
|
|
worker_processes 1;
|
|
events { worker_connections 256; }
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
sendfile on;
|
|
|
|
upstream ui_upstream {
|
|
server host.docker.internal:3000;
|
|
}
|
|
|
|
upstream api_upstream {
|
|
server host.docker.internal:8000;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name _;
|
|
|
|
ssl_certificate /etc/nginx/certs/ai-video.pem;
|
|
ssl_certificate_key /etc/nginx/certs/ai-video-key.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
location /ws/ {
|
|
proxy_pass http://api_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
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 https;
|
|
proxy_read_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
location /api/ {
|
|
proxy_pass http://api_upstream;
|
|
proxy_http_version 1.1;
|
|
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 https;
|
|
client_max_body_size 50M;
|
|
}
|
|
|
|
location /health {
|
|
proxy_pass http://api_upstream;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://ui_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
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 https;
|
|
}
|
|
}
|
|
}
|