本帖最后由 tangan 于 2023-8-18 17:32 编辑
1 概述 项目中经常会因为安全考虑,需要系统支持https的方式进行访问,对于ThingJS-X系统,目前支持两种配置方法,一种是ThingJS-X中自带https的配置方法,一种是使用nginx做代理,接下来我们一起了解一下两种方法如何配置。 2 修改配置文件方式(森X4.2.3之前产品可通过 配置文件(application-pro.properties) 支持 https 的配置) 首先第一种可以通过修改ThingJS-X的application-pro.properties配置文件,此方法为产品默认自带功能,但是此方法的注意事项是,当使用地图瓦片、地形等资源时,需要注意调用的瓦片服务或者地形服务是不是https的方式,下边简单介绍下修改步骤。 1)进入到ThingJS-X安装目录,编辑application-pro.properties文件 cd /uino/thingjsx-server/confvi application-pro.properties
2)修改开启https ## 配置是否开启httpsserver.ssl.enabled = true## 配置是开启https时,此处应改为httpsserver.http.protocol = https
森X4.3.0起就不支持https协议得配置,配置后如下图示后,服务启动会不成功;
有些遗憾,Windows版森X安装包又不自带nginx的内容,所以我们得自己动手配置nginx,用nginx配置森X的https访问
1.下载nginx 2.下载后建议最好解压至thingjsx-server同级路径下(方便找) 3.我本机 nginx.conf 配置内容(以下配置了DIX服务,如不需要可以删除/忽略) #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;
sendfile on;
keepalive_timeout 65;
underscores_in_headers on;
port_in_redirect off;
gzip on;
gzip_min_length 10k;
gzip_buffers 4 16k;
gzip_comp_level 8;
gzip_proxied any;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg image/x-ms-bmp application/octet-stream application/json;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
server {
client_max_body_size 20G;
listen 8088;
add_header Access-Control-Allow-Origin '*' always;
add_header Access-Control-Allow-Methods 'GET, PUT, POST, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
location /thing/auth {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\auth";
}
location /thing/rsm {
alias "E:\\\Program Files\\uino\\ThingJSXData\\rsm";
}
location /thing/rsm/122 {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\rsm\\122";
}
location /thing/rsm/1024 {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\rsm\\1024";
}
location /thing/campusbuilder {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\campusbuilder";
}
location /thing/citybuilder {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\citybuilder";
}
location /thing/configuration {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\configuration";
}
location /thing/dtwin {
alias "E:\\\Program Files\\uino\\ThingJSX\\thingjsx-server\\src\\main\\webapp\\dtwin";
}
location /thing {
proxy_connect_timeout 3000;
proxy_read_timeout 3000;
proxy_send_timeout 3000;
proxy_set_header Host $http_host;
proxy_pass http://10.100.40.82:1662/thing;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_connect_timeout 3000;
proxy_read_timeout 3000;
proxy_send_timeout 3000;
proxy_set_header Host $http_host;
proxy_pass http://10.100.40.82:1662/thing;
}
}
server {
client_max_body_size 20G;
listen 4434 ssl http2;
ssl_certificate "E:\\Program Files\\uino\\ThingJSX\\nginx-1.24.0\\server.crt";
ssl_certificate_key "E:\\Program Files\\uino\\ThingJSX\\nginx-1.24.0\\server.key";
ssl_session_timeout 5m;
add_header Access-Control-Allow-Origin '*' always;
add_header Access-Control-Allow-Methods 'GET, PUT, POST, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect http:// https://;
proxy_pass http://10.100.40.82:8088;
}
}
}
|
|
|
|
|
|