151 lines
4.2 KiB
Nginx Configuration File
151 lines
4.2 KiB
Nginx Configuration File
user nginx;
|
|
worker_processes auto;
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
use epoll;
|
|
multi_accept on;
|
|
}
|
|
|
|
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"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
|
|
# Gzip 压缩
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
|
|
|
# 请求体大小限制(支持大文件上传)
|
|
client_max_body_size 100m;
|
|
|
|
# 请求头缓冲区
|
|
client_header_buffer_size 128m;
|
|
large_client_header_buffers 4 128m;
|
|
|
|
# WebSocket 支持
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
# SSL 通用配置
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
|
|
ssl_prefer_server_ciphers off;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 1d;
|
|
|
|
# HTTP 重定向到 HTTPS
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
# 默认处理:未匹配的域名或 IP 访问返回 444
|
|
server {
|
|
listen 443 ssl default_server;
|
|
http2 on;
|
|
server_name _;
|
|
|
|
ssl_certificate /etc/nginx/ssl/offerpai.com.cn.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/offerpai.com.cn.key;
|
|
|
|
return 444;
|
|
}
|
|
|
|
# OfferPie 前端
|
|
# www.offerpai.com.cn → 10302
|
|
server {
|
|
listen 443 ssl;
|
|
http2 on;
|
|
server_name www.offerpai.com.cn;
|
|
|
|
ssl_certificate /etc/nginx/ssl/offerpai.com.cn.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/offerpai.com.cn.key;
|
|
|
|
location / {
|
|
proxy_pass http://172.17.0.1:10302;
|
|
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;
|
|
|
|
proxy_connect_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
proxy_read_timeout 300s;
|
|
}
|
|
}
|
|
|
|
# OfferPie Java 后端 API
|
|
# api.offerpai.com.cn → 10202
|
|
server {
|
|
listen 443 ssl;
|
|
http2 on;
|
|
server_name api.offerpai.com.cn;
|
|
|
|
ssl_certificate /etc/nginx/ssl/offerpai.com.cn.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/offerpai.com.cn.key;
|
|
|
|
location / {
|
|
proxy_pass http://172.17.0.1:10202;
|
|
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;
|
|
|
|
proxy_connect_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
proxy_read_timeout 300s;
|
|
}
|
|
}
|
|
|
|
# OfferPie Python AI 服务
|
|
# ai.offerpai.com.cn → 10502
|
|
server {
|
|
listen 443 ssl;
|
|
http2 on;
|
|
server_name ai.offerpai.com.cn;
|
|
|
|
ssl_certificate /etc/nginx/ssl/offerpai.com.cn.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/offerpai.com.cn.key;
|
|
|
|
location / {
|
|
proxy_pass http://172.17.0.1:10502;
|
|
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;
|
|
|
|
# WebSocket + 流式输出支持
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
proxy_connect_timeout 300s;
|
|
proxy_send_timeout 300s;
|
|
proxy_read_timeout 300s;
|
|
}
|
|
}
|
|
}
|