项目A配置项目B的菜单,两个是不同ip和端口
1.nginx配置
用的是nginx-1.11.130,配置文件为nginx6.conf
#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;
upstream uapserver {
server 172.26.2.224:9000;
}
server {
listen 6080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/dist;
index index.html index.htm;
#try_files index.html;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://20.30.6.134:18070/rest/api/;
## proxy_pass http://172.26.2.72:18070/rest/api/;
}
# 指向高质量的页面
location ^~/proxy/gzl/ {
#rewrite ^/proxy/gzl/(.*)$ /$1 break;
#add_header Access-Control-Allow-Origin * always;
#add_header Access-Control-Methods 'GET,POST,PUT,DELETE,OPTIONS';
#add_header Access-Control-Headers 'Accept,Origin,X-Requested-With,Content-Type,Last-Modified,User-Agent,Referer,Accept-Encoding,Accept-Language,Connection,Sec-Fetch-Mode';
#add_header Access-Control-Max-Age 86400;
#add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Headers 'Accept,Origin,X-Requested-With,Content-Type,Last-Modified,User-Agent,Referer,Accept-Encoding,Accept-Language,Connection,Sec-Fetch-Mode' always;
add_header Access-Control-Allow-Methods 'GET,POST,PUT,DELETE,OPTIONS' always;
add_header Access-Control-Allow-Credentials true always;
add_header Access-Control-Max-Age 86400 always;
proxy_pass http://uapserver/;
}
location /hqdp {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
add_header Access-Control-Allow-Credentials true;
proxy_pass http://uapserver;
}
#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;
# }
#}
}
2.login.js执行登录方法
function login(){
//alert();
var username = getQueryVariable("u");
var password = getQueryVariable("p");
var page = getQueryVariable("page");
var url=window.location.href;
var search=url.substring(0,url.indexOf("/pages"));
search=search+"/pages/";
var dzsearch=url.substring(0,url.indexOf("/hqdp_pis"));
//alert(dzsearch);
//var href="http://gzltz:9000/hqdp/hqdp_pis/pages/"+page;
//var href="http://172.26.2.224:9000/hqdp/hqdp_pis/pages/"+page;
var href=search+page;
//var href="http://172.26.2.223:8999/proxy/gzl/hqdp/hqdp_pis/pages/"+page;
var _key = "c32ad1415f6c89fee76d8457c31efb4b";
var params = {
params :$.extend(true, {
userName : username,
//password : encrypt(_key, password)
password : password
}, null)
};
// p_context_result = _getClient().sendSync("~/../iscintegrate/rest/common/loginuser/validate",
// "POST", JSON.stringify(params) );
// p_context_result = _getClient().sendSync("http://172.26.2.224:9000/hqdp/iscintegrate/rest/common/loginuser/validate",
// "POST", JSON.stringify(params) );
// p_context_result = _getClient().sendSync("http://172.26.2.223:8999/proxy/gzl/hqdp/iscintegrate/rest/common/loginuser/validate",
// "POST", JSON.stringify(params) );
p_context_result = _getClient().sendSync(dzsearch+"/iscintegrate/rest/common/loginuser/validate",
"POST", JSON.stringify(params) );
loginflag=true;
if(p_context_result.successful){
//alert(href);
//window.location.href = "http://gzltz:9000/hqdp/hqdp_pis/pages/zbsjsh/zbsjsh.jsp";
//window.location.href = href;
//systemLog('用户登录','用户登陆成功','success');
}
}
3.使用页面
配置base href,引入login.js如下
<head>
<span id="baseurl" ><base href="#"></base></span>
<script>
var url=window.location.href;
var search=url.substring(0,url.indexOf("/pages"));
search=search+"/";
var last="<base href=\""+search+"\">";
document.getElementById("baseurl").innerHTML=last;
</script>
<mx:Framework debugMode="true" />
<title>对标任务管理</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="js1/jquery/easyui142/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="js1/jquery/easyui142/themes/icon.css">
<link rel="stylesheet" type="text/css" href="js1/jquery/easyui142/themes/color.css">
<script type="text/javascript" src="pages/loginTransfer.js"></script>
<script type="text/javascript" src="pages/task/taskManage.js"></script>