Implement user access maotai.com, redirect directly to Https://www.maotai.com
1. maotai.com www.maotai.com2. http://www.maotai.com https://www.maotai.com
Nginx-lb
- NGINX-LB Certificate Generation
User--nginx (certificate)--nginx--tomcat
mkdir /data/;cd /data/openssl req -x509 -days 3650 -nodes -newkey rsa:2048 -keyout domain.key -out domain.crt -subj "/CN=www.maotai.com"
docker run -d --net=host --restart=always -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro -v /etc/localtime:/etc/localtime:ro -v /data:/data --name nginx nginx
Worker_processes auto;worker_rlimit_nofile 65535;# pid logs/nginx.pid;events {use Epoll; Worker_connections 51200;} HTTP {include mime.types; Default_type Application/octet-stream; Log_format Main ' $remote _addr $remote _user [$time _local] "$request" $http _host "$status $upstream _status $body _bytes_ Sent "$http _referer" "$http _user_agent" $ssl _protocol $ssl _cipher $upstream _addr "$request _time $upstream _respo Nse_time '; Server_name_in_redirect off; Client_max_body_size 80m; Client_header_buffer_size 16k; Large_client_header_buffers 4 16k; Sendfile on; Tcp_nopush on; Keepalive_timeout 65; Server_tokens on; gzip on; Gzip_min_length 1k; Gzip_buffers 4 16k; Gzip_proxied any; Gzip_http_version 1.1; Gzip_comp_level 3; Gzip_types text/plain application/x-javascript text/css application/xml; Gzip_vary on; # 80-80# Server {# listen 80;# server_name www.maotai.com;# Proxy_connect_timeouT 1s;# # proxy_read_timeout 600;# # proxy_send_timeout 600;# proxy_buffer_size 128k;# Proxy_bu Ffers 4 256k;# proxy_busy_buffers_size 256k;# location/{# Proxy_next_upstream Error timeout Inv Alid_header http_500 http_503 http_404 http_502 http_504;# proxy_pass http://192.168.14.11:80;# ProX Y_set_header Host $host; # proxy_set_header X-real-ip $remote _addr;# proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;#}##} #443 -8080 server {listen 443 SSL; server_name www.maotai.com; SSL on; SSL_CERTIFICATE/DATA/DOMAIN.CRT; Ssl_certificate_key/data/domain.key; server_name Web-https; Proxy_connect_timeout 1s; # Proxy_read_timeout 600; # Proxy_send_timeout 600; Proxy_buffer_size 128k; Proxy_buffers 4 256k; Proxy_busy_buffers_size 256k; Location/{proxy_next_upsTream Error timeout Invalid_header http_500 http_503 http_404 http_502 http_504; Proxy_pass http://192.168.14.11:8080; Proxy_set_header Host $host; Proxy_set_header X-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; }}}stream {Log_format log_stream [$time _local] $protocol $status $bytes _sent $bytes _received $session _time; Access_log/var/log/nginx/access.log Log_stream; Error_log/var/log/nginx/error.log; server {Listen 80; Proxy_timeout 600s; Proxy_pass 192.168.14.11:80; }}
Nginx Configuration
Worker_processes 1;events {worker_connections 1024;} HTTP {include mime.types; Default_type Application/octet-stream; Sendfile on; Keepalive_timeout 65; server {Listen 80; server_name www.maotai.com; Proxy_connect_timeout 1s; # Proxy_read_timeout 600; # Proxy_send_timeout 600; Proxy_buffer_size 128k; Proxy_buffers 4 256k; Proxy_busy_buffers_size 256k; Location/{Proxy_next_upstream error timeout Invalid_header http_500 http_503 http_404 http_502 http_504; Proxy_pass http://127.0.0.1:8080; Proxy_set_header Host $host; Proxy_set_header X-real-ip $remote _addr; Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; } if ($request _uri!~ (/wechat|/supervisor|/front/account/invitespread|/front/thirdparty/thirdpartyaction/netloanh ome) {rewrite ^/(. *) https://www.maotai.com/$1 permanent; } } server {Listen 80; server_name maotai.com; Rewrite ^/(. *) http://www.maotai.com/$1 permanent; }}
[Svc]nginx cluster HTTPS access configuration