前言
最近购入一个非常小的小机,线路非常不错是香港大陆优化的机器,想着没不了啥,就试试给一个AI站点做个CDN试试,可以看本站的测试《BitsFlowCloud:259.99/年/香港大陆优化/3核/3G/1.5T@200M宽带-测试》
涉及文件
- docker-compose.yml Docker编排文件
- nginx.conf Nginx 配置文件
nginx.conf 文件内容
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
' $upstream_cache_status';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# 设置缓存
proxy_cache_path /data/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m;
proxy_cache_key "$scheme$request_method$host$request_uri";
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
server {
listen 80;
server_name www.ai-ku.cn;
# 强制HTTPS(可选)
# return 301 https://$host$request_uri;
location / {
proxy_pass http://154.219.105.97; # 源站地址
proxy_cache my_cache;
proxy_cache_valid 200 304 30m;
add_header Cache-Control "public, max-age=1800";
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;
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico|svg|woff|woff2|ttf|eot)$ {
proxy_pass http://154.219.105.97;
proxy_cache my_cache;
proxy_cache_valid 200 30d;
add_header Cache-Control "public, max-age=2592000"; # 30天
}
}
}
docker-compose.yml 文件内容
version: '3'
services:
nginx:
image: nginx:alpine
container_name: nginx-cdn
ports:
- "80:80" # 自行调整端口
- "443:443" # 自行调整端口
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro # 映射配置文件
- ./cache:/data/cache # 映射缓存目录
- ./ssl:/etc/ssl/certs # 映射SSL证书(可选)
restart: always
- THE END -
资源搜集自互联网,如有侵犯权利,请及时联系我们,我们将尽快处理。
博客仅为分享信息,不介入任何交易纠纷,您在购买和使用中遇到任何问题请联络相关提供商处理。