XXX系统架构随记
该系统用到的技术:Windows server,NGINX ,Tomcat,Java,Redis,MySQL
用户访问网站 --> nginx —> 反代到Tomcat的 8082
Tomcat 8082端口
tomcat7\conf\server.xml里面仅配置端口8082。
tomcat7\conf\Catalina\localhost\ZCwechat.xml
对应的放web项目:
nginx
https://www.gzzcbwg.com/ZCwechat/shiro/ZCLoging?token=917193b0b90ad7559ad96804cf01b273
该项目的nginx.conf
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_tokens off;
server {
listen 443 ssl;
listen 80;
server_name www.gzzcbwg.com;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
ssl_certificate ssl/gzzcbwg.com.cer;
ssl_certificate_key ssl/gzzcbwg.com.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-RC4-SHA:!ECDHE-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:!RC4-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!CBC:!EDH:!kEDH:!PSK:!SRP:!kECDH';
ssl_prefer_server_ciphers on;
fastcgi_connect_timeout 1800;
fastcgi_send_timeout 1800;
client_max_body_size 1000m;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
location /.well-known {
root MP;
}
if ($scheme = http) {
return 301 https://$host$request_uri;
}
if ($request_uri = /) {
return 301 https://www.gzzcbwg.com/zcmuseum;
}
location /activiti-app {
proxy_pass http://10.10.0.206:8081;
}
location /zcmuseum {
proxy_pass http://10.10.0.206:8082;
}
location /ZCwechat {
proxy_pass http://10.10.0.57:8082;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Scheme $scheme;
proxy_redirect http:// $scheme://;
}
location /ZCteens {
proxy_pass http://10.10.0.57:8081;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Scheme $scheme;
proxy_redirect http:// $scheme://;
}
}
server {
listen 8000 ssl;
server_name www.gzzcbwg.com;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
ssl_certificate ssl/gzzcbwg.com.cer;
ssl_certificate_key ssl/gzzcbwg.com.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-RC4-SHA:!ECDHE-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:!RC4-SHA:HIGH:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!CBC:!EDH:!kEDH:!PSK:!SRP:!kECDH';
ssl_prefer_server_ciphers on;
fastcgi_connect_timeout 1800;
fastcgi_send_timeout 1800;
client_max_body_size 1000m;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
if ($scheme = http) {
return 301 https://$host$request_uri;
}
if ($request_uri = /) {
return 301 http://www.gzzcbwg.com:8000/zcmuseum;
}
location /activiti-app {
proxy_pass http://10.10.0.206:8081;
}
location /zcmuseum {
proxy_pass http://10.10.0.206:8082;
if ( $request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
}
其他随记:
nginx.conf 1
#user nobody;
user root;
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;
#负载
upstream natural-ui{
server 10.10.88.109:8000
}
upstream naturalTicket-ui{
server 10.10.88.109:8001
}
upstream ticket-mobile{
server 10.10.88.109:8002
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8000;
server_name 192.168.0.16;
client_max_body_size 200M;
#charset koi8-r;
#access_log logs/host.access.log main;
root /opt/Applications/web/natural-ui;
location ~* ^/(code|auth|admin|cdnaturemms-portal|cdnaturemms-dr|cdnaturemms-cp|cdnaturemms-oa|cdnaturemms-ad|ticket|web|mobile|cdnaturemms-subsys|guide-pc) {
proxy_pass http://192.168.0.7:9999;
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 600s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /callback {
proxy_pass http://119.23.200.66:8090;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /files/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET,POST';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
alias /mnt/sdb/bjmms/files/;
}
location /cdnaturalTicket {
alias /opt/Applications/web/naturalTicket-ui; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrTicketWx {
alias /opt/Applications/web/ticket-mobile; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /socket/ws {
proxy_pass http://192.168.0.16:18000;
# WebScoket Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ws {
proxy_pass http://192.168.0.16:18000;
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_read_timeout 120s;
proxy_set_header Upgrade websocket;
proxy_set_header Connection Upgrade;
}
location /modelFile/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET,POST';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
alias /mnt/sdb/bjmms/files/;
}
location /cdzrGuide {
alias /opt/Applications/ahdzmap/cdzrGuide; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrGuideMobile {
alias /opt/Applications/ahdzmap/cdzrGuideMobile; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrSdkMap {
alias /opt/Applications/ahdzmap/sdkMap; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrMap {
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_pass http://192.168.0.16:8183; # 需要改为对应的导览后台服务地址
client_max_body_size 10m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8001;
server_name 192.168.0.16;
root /opt/Applications/web/naturalTicket-ui; #vue项目的打包后的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
location ~* ^/(code|auth|admin|gen|daemon|tx|act|pay|monitor|job|mp|web) {
proxy_pass http://192.168.0.7:9999;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
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 8802;
server_name 192.168.0.16;
#charset koi8-r;
#access_log logs/host.access.log main;
root /opt/Applications/web/ticket-mobile;
location ~* ^/(mobile) {
proxy_pass http://192.168.0.7:9999;
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* ^/ {
proxy_set_header X-Real-IP $remote_addr;
expires -1s;
add_header Cache-Control no-cache;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
nginx.conf 2
#user nobody;
user root;
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 localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
server {
listen 8000;
server_name 172.16.20.139;
client_max_body_size 200M;
#charset koi8-r;
#access_log logs/host.access.log main;
root /opt/Applications/web/natural-ui;
location ~* ^/(code|auth|admin|cdnaturemms-portal|cdnaturemms-dr|cdnaturemms-cp|cdnaturemms-oa|cdnaturemms-ad|ticket|web|mobile|cdnaturemms-subsys|guide-pc) {
proxy_pass http://127.0.0.1:9999;
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 600s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /callback {
proxy_pass http://119.23.200.66:8090;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /files/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET,POST';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
alias /mnt/sdb/bjmms/files/;
}
location /cdnaturalTicket {
alias /opt/Applications/web/naturalTicket-ui; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrTicketWx {
alias /opt/Applications/web/ticket-mobile; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /socket/ws {
proxy_pass http://172.16.20.139:18001;
# WebScoket Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ws {
proxy_pass http://172.16.20.139:18001;
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_read_timeout 120s;
proxy_set_header Upgrade websocket;
proxy_set_header Connection Upgrade;
}
location /modelFile/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET,POST';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
alias /mnt/sdb/bjmms/files/;
}
location /cdzrGuide {
alias /opt/Applications/ahdzmap/cdzrGuide; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrGuideMobile {
alias /opt/Applications/ahdzmap/cdzrGuideMobile; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrSdkMap {
alias /opt/Applications/ahdzmap/sdkMap; # 需要改为本地对应的目录
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
location /cdzrMap {
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_pass http://127.0.0.1:8183; # 需要改为对应的导览后台服务地址
client_max_body_size 10m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 8868;
server_name 172.16.20.139;
root /opt/Applications/web/okay-ui; #vue项目的打包后的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
location ~* ^/(code|auth|admin|gen|daemon|tx|act|pay|monitor|job|mp) {
proxy_pass http://127.0.0.1:9999;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
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 8003;
server_name 172.16.20.139;
root /opt/Applications/web/naturalTicket-ui; #vue项目的打包后的dist
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
location ~* ^/(code|auth|admin|gen|daemon|tx|act|pay|monitor|job|mp|web) {
proxy_pass http://127.0.0.1:9999;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
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 8801;
server_name 172.16.20.139;
#charset koi8-r;
#access_log logs/host.access.log main;
root /opt/Applications/web/ticket-mobile;
location ~* ^/(mobile) {
proxy_pass http://127.0.0.1:9999;
proxy_connect_timeout 15s;
proxy_send_timeout 15s;
proxy_read_timeout 15s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* ^/ {
proxy_set_header X-Real-IP $remote_addr;
expires -1s;
add_header Cache-Control no-cache;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}