server {
listen 80;
server_name api.test.com;
index index.html;
rewrite_log on;
charset utf8;
access_log ~/log/nginx/project.access.log main;
error_log ~/log/nginx/project.error.log notice;
# txt 文件重定向到txt.test.cn/txt/ 下
location ~\.txt$ {
rewrite ^/(.+)$ /txt/$1 break;
proxy_pass http://txt.test.cn;
}
# /static/image 文件重定向到image.test.cn/ 下
location /static/image/ {
proxy_pass http://image.test.cn;
}
# static 文件转到项目文件的app下查找
location /static {
proxy_redirect off;
root ~/project_dir/project/app;
access_log off;
expires 30d;
add_header Cache-Control public;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/project.sock;
client_max_body_size 500M;
client_body_buffer_size 1024k;
}
}
Nginx 使用基础配置
最新推荐文章于 2024-06-04 18:30:11 发布