37 lines
680 B
Markdown
37 lines
680 B
Markdown
---
|
||
title: "Nginx"
|
||
type: entity
|
||
tags: [web-server, reverse-proxy]
|
||
sources: [tiktok-pm-python-django-project.md]
|
||
last_updated: 2026-04-14
|
||
---
|
||
|
||
## Definition
|
||
Nginx是一个高性能的HTTP服务器和反向代理。
|
||
|
||
## Role in TikTok PM Project
|
||
- 作为反向代理,将请求转发给Gunicorn
|
||
- 提供静态文件服务(/static/和/media/)
|
||
- 监听80端口
|
||
|
||
## Configuration
|
||
```nginx
|
||
upstream web {
|
||
server web:8000;
|
||
}
|
||
|
||
server {
|
||
listen 80;
|
||
location /static/ {
|
||
alias /app/staticfiles/;
|
||
}
|
||
location / {
|
||
proxy_pass http://web;
|
||
}
|
||
}
|
||
```
|
||
|
||
## Connections
|
||
- [[Nginx]] ← proxies_to ← [[Gunicorn]]
|
||
- [[Nginx]] ← serves_static ← [[Django]]
|