#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } 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; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name xxxx.pub; location / { proxy_pass http://localhost:8081; proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 32k; proxy_buffers 4 64k; #proxy_buffering off; proxy_busy_buffers_size 128k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name *.xxxx.pub; location / { # 泛域名开始配置 #if ( $host ~* (.*)\.(.*)\.(.*)\.(.*) ) { # set $domain $1; #获取当前的 域名前缀 # } proxy_pass http://localhost:8081; proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 32k; proxy_buffers 4 64k; #proxy_buffering off; proxy_busy_buffers_size 128k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 443 ssl; server_name xxxx.pub; # localhost 修改为您证书绑定的域名。 ssl_certificate /etc/nginx/cert/xxxx_integrated.crt; #将 domain name.pem 替换成您证书的文件名。 ssl_certificate_key /etc/nginx/cert/xxxx.key; #将domain name.key替换成您证书的密钥文件名。 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。 location / { proxy_pass https://localhost:8443; #root html; #index index.html index.htm; proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 32k; proxy_buffers 4 64k; #proxy_buffering off; proxy_busy_buffers_size 128k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; 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 https; } } server { listen 443 ssl; server_name *.xxxx.pub; # localhost 修改为您证书绑定的域名。 ssl_certificate /etc/nginx/cert/xxxx_integrated.crt; #将 domain name.pem 替换成您证书的文件名。 ssl_certificate_key /etc/nginx/cert/xxxx.key; #将domain name.key替换成您证书的密钥文件名。 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。 location / { # 泛域名开始配置 # if ( $host ~* (.*)\.(.*)\.(.*)\.(.*) ) { # set $domain $1; #获取当前的 域名前缀 # } proxy_pass https://localhost:8443; proxy_connect_timeout 300s; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 32k; proxy_buffers 4 64k; #proxy_buffering off; proxy_busy_buffers_size 128k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; 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 https; } } }
重要信息:
将主域名的拦截和泛域名的拦截分开;
拦截后不需要解析泛域名的前缀,saas的域名识别完全交给jbolt程序识别;
泛域名申请:
泛域名证书申请的是 joyssl 免费版90天有效期,到期在申请
地址:https://www.joyssl.com/certificate/select/free.html
项目:JBolt极速开发平台