user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
add_header X-Frame-Options SAMEORIGIN;
#keepalive_timeout 0;
keepalive_timeout 2400;
#gzip on;
proxy_connect_timeout 6000; #单位秒
proxy_send_timeout 6000; #单位秒
proxy_read_timeout 6000; #单位秒
proxy_buffer_size 1024k;
proxy_buffers 4 1024k;
proxy_busy_buffers_size 1024k;
proxy_temp_file_write_size 1024k;
include /etc/nginx/conf.d/framework_upstream.conf;
server {
listen 8099;
server_name localhost;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_connect_timeout 600;
client_max_body_size 5120m;
}
server {
#listen 9099;
listen 443 ssl default;
server_name localhost;
location / {
if ( $request_uri = "/" ) {
rewrite "/" https://10.42.34.100:$server_port/dgdpsportal/#/index break;
}
}
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_connect_timeout 600;
client_max_body_size 5120m;
#允许跨域请求的域,* 代表所有
add_header 'Access-Control-Allow-Origin' *;
#允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
#允许请求的方法,比如 GET/POST/PUT/DELETE
add_header 'Access-Control-Allow-Methods' *;
#允许请求的header
add_header 'Access-Control-Allow-Headers' *;
# 引用ssl证书
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
# 协议优化(可选,优化https协议,增强安全性)
ssl_protocols TLSv1.2;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
include /etc/nginx/conf.d/framework_location.conf;
}
}
proxyconnect_timeout :后端服务器连接的超时时间发起握手等候响应超时时间(默认60秒) proxyread_timeout:连接成功后等候后端服务器响应时间其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间) proxy_send_timeout :后端服务器数据回传时间就是在规定时间之内后端服务器必须传完所有的数据
说明,重定向实现 在nginx中配置ip直接访问的默认站点
location / {
if ( $request_uri = "/" ) {
rewrite "/" https://10.42.34.100:$server_port/dgdpsportal/#/index break;
}
}
framework_upstream.conf
upstream idatafusion {
server 127.0.0.1:10000 weight=1;
}
framework_location.conf
location /idatafusion{
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cookie_path /idatafusion /idatafusion;
proxy_set_header Cookies $http_cookies;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffer_size 128k;
proxy_buffers 8 128k;
proxy_busy_buffers_size 128k;
proxy_pass http://idatafusion/idatafusion;
}