190 lines
5.3 KiB
Plaintext
190 lines
5.3 KiB
Plaintext
# NAC区块链 Nginx配置
|
||
# 用于NRPC3.0端点的反向代理和SSL终止
|
||
|
||
# NRPC3.0 HTTP端点
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name rpc.newassetchain.io;
|
||
|
||
# 重定向到HTTPS
|
||
return 301 https://$server_name$request_uri;
|
||
}
|
||
|
||
server {
|
||
listen 443 ssl http2;
|
||
listen [::]:443 ssl http2;
|
||
server_name rpc.newassetchain.io;
|
||
|
||
# SSL证书配置
|
||
ssl_certificate /etc/nginx/ssl/_.newassetchain.io.pem;
|
||
ssl_certificate_key /etc/nginx/ssl/_.newassetchain.io.key;
|
||
|
||
# SSL优化
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
ssl_prefer_server_ciphers on;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 10m;
|
||
|
||
# 安全头
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header X-XSS-Protection "1; mode=block" always;
|
||
|
||
# CORS配置(允许区块浏览器访问)
|
||
add_header Access-Control-Allow-Origin "*" always;
|
||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
||
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
|
||
|
||
# 处理OPTIONS请求
|
||
if ($request_method = 'OPTIONS') {
|
||
return 204;
|
||
}
|
||
|
||
# 反向代理到NRPC3.0端点
|
||
location / {
|
||
proxy_pass http://127.0.0.1:18545;
|
||
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 $scheme;
|
||
|
||
# 超时设置
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
proxy_read_timeout 60s;
|
||
|
||
# 缓冲设置
|
||
proxy_buffering off;
|
||
proxy_request_buffering off;
|
||
}
|
||
|
||
# 日志
|
||
access_log /var/log/nginx/nac-rpc-access.log;
|
||
error_log /var/log/nginx/nac-rpc-error.log;
|
||
}
|
||
|
||
# NRPC3.0 WebSocket端点
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name ws.newassetchain.io;
|
||
|
||
# 重定向到HTTPS
|
||
return 301 https://$server_name$request_uri;
|
||
}
|
||
|
||
server {
|
||
listen 443 ssl http2;
|
||
listen [::]:443 ssl http2;
|
||
server_name ws.newassetchain.io;
|
||
|
||
# SSL证书配置
|
||
ssl_certificate /etc/nginx/ssl/_.newassetchain.io.pem;
|
||
ssl_certificate_key /etc/nginx/ssl/_.newassetchain.io.key;
|
||
|
||
# SSL优化
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
ssl_prefer_server_ciphers on;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 10m;
|
||
|
||
# 安全头
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
|
||
# WebSocket反向代理
|
||
location / {
|
||
proxy_pass http://127.0.0.1:18546;
|
||
proxy_http_version 1.1;
|
||
|
||
# WebSocket升级
|
||
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 $scheme;
|
||
|
||
# 超时设置(WebSocket需要更长时间)
|
||
proxy_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
|
||
# 缓冲设置
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# 日志
|
||
access_log /var/log/nginx/nac-ws-access.log;
|
||
error_log /var/log/nginx/nac-ws-error.log;
|
||
}
|
||
|
||
# 区块浏览器端点
|
||
server {
|
||
listen 80;
|
||
listen [::]:80;
|
||
server_name explorer.newassetchain.io;
|
||
|
||
# 重定向到HTTPS
|
||
return 301 https://$server_name$request_uri;
|
||
}
|
||
|
||
server {
|
||
listen 443 ssl http2;
|
||
listen [::]:443 ssl http2;
|
||
server_name explorer.newassetchain.io;
|
||
|
||
# SSL证书配置
|
||
ssl_certificate /etc/nginx/ssl/_.newassetchain.io.pem;
|
||
ssl_certificate_key /etc/nginx/ssl/_.newassetchain.io.key;
|
||
|
||
# SSL优化
|
||
ssl_protocols TLSv1.2 TLSv1.3;
|
||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||
ssl_prefer_server_ciphers on;
|
||
ssl_session_cache shared:SSL:10m;
|
||
ssl_session_timeout 10m;
|
||
|
||
# 安全头
|
||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||
add_header X-Content-Type-Options "nosniff" always;
|
||
add_header X-XSS-Protection "1; mode=block" always;
|
||
|
||
# 反向代理到Vite开发服务器
|
||
location / {
|
||
proxy_pass http://127.0.0.1:3002;
|
||
proxy_http_version 1.1;
|
||
|
||
# WebSocket支持(Vite HMR)
|
||
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 $scheme;
|
||
|
||
# 超时设置
|
||
proxy_connect_timeout 60s;
|
||
proxy_send_timeout 60s;
|
||
proxy_read_timeout 60s;
|
||
|
||
# 缓冲设置
|
||
proxy_buffering off;
|
||
}
|
||
|
||
# 日志
|
||
access_log /var/log/nginx/nac-explorer-access.log;
|
||
error_log /var/log/nginx/nac-explorer-error.log;
|
||
}
|