package globals import ( _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" "go.uber.org/zap" ) var ( SugarLogger *zap.SugaredLogger db *sqlx.DB err error AliKey = "LTAI4FwZN7pp4dACQHoapkZQ" AliSecret = "NTegceUFX0FdfMovqCDzqcIKmhcoOu" SmsSignName = "京西菜市" SmsMobileVerifyTemplate = "SMS_175583158" TongLianPayCallBack = "http://callback.jxc4.com/wxpay/msg/" //通联回调地址 ) func init() { logger, _ := zap.NewDevelopment() SugarLogger = logger.Sugar() sqlStr := "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true" db, err = sqlx.Connect("mysql", sqlStr) if err != nil { SugarLogger.Debugf("加载数据库失败!err :%v", err) SugarLogger.Debugf("loading data base err :%v", err) } //db.SetConnMaxLifetime(time.Second * 10) db.SetMaxOpenConns(200) // 设置与数据库建立连接的最大数目 db.SetMaxIdleConns(10) // 设置连接池中的最大闲置连接数 } func GetDB() *sqlx.DB { return db } func GetTxDb() *sqlx.Tx { tx, _ := db.Beginx() return tx } //log_format json_log escape=json '{"realip":"$remote_addr","@timestamp":"$time_iso8601","host":"$http_host","request":"$request","req_body":"$request_body","status":"$status","size":$body_bytes_sent,"ua":"$http_user_agent","cookie":"$http_cookie","req_time":"$request_time","uri":"$uri","referer":"$http_referer","xff":"$http_x_forwarded_for","ups_status":"$upstream_status","ups_addr":"$upstream_addr","ups_time":"$upstream_response_time", "token":"$http_token", "content_type":"$content_type"}'; // //client_body_buffer_size 10m; // // //server { // listen 80; // listen 443 ssl; // server_name www.rosy.net.cn; // ssl_certificate /jxdata/ssl/2724501_www.rosy.net.cn/6000180_www.rosy.net.cn.pem; // ssl_certificate_key /jxdata/ssl/2724501_www.rosy.net.cn/6000180_www.rosy.net.cn.key; // // root /jxdata/webroot/jingxicaishi/; // index index.html index.htm index.php; // access_log /var/log/nginx/joomla.log json_log; // error_page 404 /; // // location ~ \.php { // fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; // fastcgi_pass gold2.int.jxc4.com:9000; // // fastcgi_index index.php; // include fastcgi_params; // // fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; // fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; // fastcgi_param PATH_INFO $fastcgi_path_info; // fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; // // fastcgi_read_timeout 1800; #有效限制访问超时 // fastcgi_connect_timeout 1800; // fastcgi_send_timeout 1800; // } //} // //server { // listen 80; // listen 443 ssl; // // server_name localhost; // // #charset koi8-r; // #access_log /var/log/nginx/host.access.log main; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // location / { // root /usr/share/nginx/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 /usr/share/nginx/html; // } //} // //server { // listen 80; // server_name del.www.jingxicaishi.com; // root /jxdata/webroot/jingxicaishi/; // index index.html index.htm index.php; // access_log /var/log/nginx/jingxicaishi.log json_log; // // location ~ \.php { // fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; // fastcgi_pass test1.int.jxc4.com:9000; // // fastcgi_index index.php; // include fastcgi_params; // // fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; // fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; // fastcgi_param PATH_INFO $fastcgi_path_info; // fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; // // fastcgi_read_timeout 700; #有效限制访问超时 // fastcgi_connect_timeout 700; // fastcgi_send_timeout 700; // } //} // //server { // listen 80; // listen 443 ssl; // server_name callback.jxc4.com callback.int.jxc4.com; // // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // location / { // access_log /var/log/nginx/callback.log json_log; // proxy_pass http://gold1.int.jxc4.com:8080; // } //} // //server { // listen 80; // server_name callback.jd2.jxc4.com; // location /djsw/ { // rewrite /djsw/(.*)$ /djsw2/$1 break; // access_log /var/log/nginx/jd2callback.log json_log; // proxy_pass http://gold1.int.jxc4.com:8080; // } // location /djsw2/ { // access_log /var/log/nginx/jd2callback.log json_log; // proxy_pass http://gold1.int.jxc4.com:8080; // } //} // // //server { // listen 80; // server_name callback-jxgy.jxc4.com; // location / { // access_log /var/log/nginx/callback-jxgy.log json_log; // proxy_pass http://gold1.int.jxc4.com:8088; // } //} // //server { // listen 80; // server_name callback-gblm.jxc4.com; // location / { // access_log /var/log/nginx/callback-gblm.log json_log; // proxy_pass http://gold1.int.jxc4.com:8090; // } //} // // //server { // listen 80; // server_name callback.test.jxc4.com; // location / { // access_log /var/log/nginx/callback-jxgy.log json_log; // proxy_pass http://test1.int.jxc4.com:8080; // } //} //server { // listen 80; // server_name callback.test.jxc4.com; // location / { // access_log /var/log/nginx/callback-gblm.log json_log; // proxy_pass http://test1.int.jxc4.com:8080; // } //} // // // //server { // listen 80; // server_name zabbix.jxc4.com; // root /usr/share/zabbix/; // index index.html index.php; // # Load configuration files for the default server block. // # include /etc/nginx/default.d/*.conf; // // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } // // location ~ \.php(.*)$ { // fastcgi_pass 127.0.0.1:9000; // fastcgi_index index.php; // fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; // fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; // fastcgi_param PATH_INFO $fastcgi_path_info; // fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; // fastcgi_read_timeout 30000; #有效限制访问超时 // include fastcgi_params; // } //} // //server { // listen 80; // server_name jenkins.jxc4.com; // location / { // 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_set_header X-Forwarded-Proto $scheme; // // proxy_read_timeout 90; // proxy_redirect http://localhost:8088 http://jenkins.jxc4.com; // proxy_pass http://localhost:8088; // add_header 'X-SSH-Endpoint' 'jenkins.jxc4.com' always; // } //} // //server { // listen 80; // server_name notebook.jxc4.com; // location / { // 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_set_header X-Forwarded-Proto $scheme; // // proxy_read_timeout 90; // proxy_redirect http://localhost:8888 http://notebook.jxc4.com; // proxy_pass http://localhost:8888; // add_header 'X-SSH-Endpoint' 'notebook.jxc4.com' always; // // # WebSocket support // proxy_http_version 1.1; // proxy_set_header Upgrade $http_upgrade; // proxy_set_header Connection "upgrade"; // // proxy_next_upstream error; // } //} // //server { // listen 80; // server_name alpha.jxc4.com; // root /jxdata/new_web/alpha/; // index index.html index.php; // access_log /var/log/nginx/alpha.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://test1.int.jxc4.com:8088; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://test1.int.jxc4.com:8088; // } // // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // server_name beta.jxc4.com; // root /jxdata/new_web/beta/; // index index.html index.php; // access_log /var/log/nginx/beta.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://test1.int.jxc4.com:8080; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://test1.int.jxc4.com:8080; // } // // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // // server_name www.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/prod/; // index index.html; // access_log /var/log/nginx/jxstore.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8080; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // proxy_set_header Upgrade $http_upgrade; // proxy_set_header Connection "Upgrade"; // if ($request_method = 'POST') { // add_header 'Access-Control-Allow-Origin' '*'; // add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, OPTIONS'; // add_header 'Access-Control-Allow-Headers' '*'; // } // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8080; // } // location /jd/ { // rewrite /jd/(.*)$ /$1 break; // proxy_pass https://daojia.jd.com; // } // location /jd2/ { // rewrite /jd2/(.*)$ /$1 break; // proxy_pass https://store.jd.com; // } // location /sta-store.jddj.com/ { // rewrite /sta-store.jddj.com/(.*)$ /$1 break; // proxy_pass https://sta-store.jddj.com; // } // location /jx/h5/ // { // rewrite ^/jx/h5/(.*)$ http://wx.jxc4.com/$1 permanent; // } // location /alpha/ { // rewrite /alpha/(.*)$ /$1 break; // proxy_pass http://alpha.jxc4.com; // } // location /beta/ { // rewrite /beta/(.*)$ /$1 break; // proxy_pass http://beta.jxc4.com; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // // server_name www.jingxidj.cn; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/prod/; // index index.html; // access_log /var/log/nginx/jxstore.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8080; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // proxy_set_header Upgrade $http_upgrade; // proxy_set_header Connection "Upgrade"; // if ($request_method = 'POST') { // add_header 'Access-Control-Allow-Origin' '*'; // add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, OPTIONS'; // add_header 'Access-Control-Allow-Headers' '*'; // } // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8080; // } // location /jd/ { // rewrite /jd/(.*)$ /$1 break; // proxy_pass https://daojia.jd.com; // } // location /jd2/ { // rewrite /jd2/(.*)$ /$1 break; // proxy_pass https://store.jd.com; // } // location /sta-store.jddj.com/ { // rewrite /sta-store.jddj.com/(.*)$ /$1 break; // proxy_pass https://sta-store.jddj.com; // } // location /jx/h5/ // { // rewrite ^/jx/h5/(.*)$ http://wx.jxc4.com/$1 permanent; // } // location /alpha/ { // rewrite /alpha/(.*)$ /$1 break; // proxy_pass http://alpha.jxc4.com; // } // location /beta/ { // rewrite /beta/(.*)$ /$1 break; // proxy_pass http://beta.jxc4.com; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // // server_name www-jxgy.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/prod/; // index index.html; // access_log /var/log/nginx/jxstore-jxgy.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8088; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // proxy_set_header Upgrade $http_upgrade; // proxy_set_header Connection "Upgrade"; // // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8088; // } // location /jd/ { // rewrite /jd/(.*)$ /$1 break; // proxy_pass https://daojia.jd.com; // } // location /jd2/ { // rewrite /jd2/(.*)$ /$1 break; // proxy_pass https://store.jd.com; // } // location /jx/h5/ // { // rewrite ^/jx/h5/(.*)$ http://wx-jxgy.jxc4.com/$1 permanent; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // //server { // listen 80; // listen 443 ssl; // // server_name www-gblm.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/prod/; // index index.html; // access_log /var/log/nginx/jxstore-gblm.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8090; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // proxy_set_header Upgrade $http_upgrade; // proxy_set_header Connection "Upgrade"; // // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8090; // } // location /jd/ { // rewrite /jd/(.*)$ /$1 break; // proxy_pass https://daojia.jd.com; // } // location /jd2/ { // rewrite /jd2/(.*)$ /$1 break; // proxy_pass https://store.jd.com; // } // location /jx/h5/ // { // rewrite ^/jx/h5/(.*)$ http://wx-gblm.jxc4.com/$1 permanent; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // // //server { // listen 80; // listen 443 ssl; // // server_name wx.jxc4.com userstore.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_wx/prod/; // index index.html; // access_log /var/log/nginx/jxwx.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8080; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /jxgy/ { // rewrite /jxgy/(.*)$ /$1 break; // proxy_pass http://wx-jxgy.jxc4.com; // } // location /gblm/ { // rewrite /gblm/(.*)$ /$1 break; // proxy_pass http://wx-gblm.jxc4.com; // } // // location /allinpaysc/ { // rewrite /allinpaysc/(.*)$ /$1 break; // proxy_pass http://chl.allinpaysc.com; // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8080; // } // location /jx/h5/ // { // proxy_pass http://wx.jxc4.com/; // } // location /alpha/ { // rewrite /alpha/(.*)$ /$1 break; // proxy_pass https://wx-alpha.jxc4.com; // } // location /beta/ { // rewrite /beta/(.*)$ /$1 break; // proxy_pass http://wx-beta.jxc4.com; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // // server_name wx-alpha.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_wx/prod/; // index index.html; // access_log /var/log/nginx/jxwx-alpha.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://test1.int.jxc4.com:8088; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://test1.int.jxc4.com:8088; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // // server_name wx-beta.jxc4.com; // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_wx/beta/; // index index.html; // access_log /var/log/nginx/jxwx-beta.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://test1.int.jxc4.com:8080; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://test1.int.jxc4.com:8088; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // //server { // listen 80; // listen 443 ssl; // server_name wx-jxgy.jxc4.com; // // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_wx/prod/; // index index.html; // access_log /var/log/nginx/jxwx-jxgy.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8088; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8088; // } // location /jx/h5/ // { // proxy_pass http://wx-jxgy.jxc4.com/; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // //server { // listen 80; // listen 443 ssl; // server_name wx-gblm.jxc4.com; // // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_wx/prod/; // index index.html; // access_log /var/log/nginx/jxwx-gblm.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8090; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8090; // } // location /jx/h5/ // { // proxy_pass http://wx-gblm.jxc4.com/; // } // error_page 404 /404.html; // location = /40x.html { // } // // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // // //server { // listen 80; // listen 443 ssl; // server_name app.jxc4.com; // // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/jxapp/; // index index.html; // access_log /var/log/nginx/jxwx-jxgy.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8088; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8088; // } // location /jx/h5/{ // proxy_pass http://app.jxc4.com/; // } // location /app { // proxy_pass https://wx.jxc4.com/; // } // error_page 404 /404.html; // location = /40x.html { // } // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // // //server { // listen 80; // listen 443 ssl; // server_name app.jxc4.com; // // ssl_certificate /jxdata/ssl/jxc4.com.pem; // ssl_certificate_key /jxdata/ssl/jxc4.com.key; // // root /jxdata/new_web/jxapp/; // index index.html; // access_log /var/log/nginx/jxwx-gblm.log json_log; // // include /etc/nginx/default.d/*.conf; // location /v2/ { // rewrite /api/(.*)$ /$1 break; // proxy_pass http://gold1.int.jxc4.com:8090; // proxy_set_header Host $http_host; // proxy_set_header X-Forwarded-For $remote_addr; // proxy_set_header X-real-ip $remote_addr; // } // location /swagger/ { // proxy_pass http://gold1.int.jxc4.com:8090; // } // location /jx/h5/{ // proxy_pass http://app.jxc4.com/; // } // location /app { // proxy_pass https://wx.jxc4.com/; // } // error_page 404 /404.html; // location = /40x.html { // } // error_page 500 502 503 504 /50x.html; // location = /50x.html { // } //} // // // // //