Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置https #84

Closed
lazzyfu opened this issue Sep 25, 2018 · 2 comments
Closed

配置https #84

lazzyfu opened this issue Sep 25, 2018 · 2 comments

Comments

@lazzyfu
Copy link
Owner

lazzyfu commented Sep 25, 2018

该系统支持配置https支持,需要手动修改如下代码:

https流程:
web --> https(自己部署的ssl证书) --> docker(nginx)

vim static/c_websocket.js 
let socket = new WebSocket('ws://' + window.location.host + '/ws/');
修改为:
let socket = new WebSocket('wss://' + window.location.host + '/ws/');
vim templates/sqlquery/sql_query.html
let socket = new WebSocket('ws://' + window.location.host + '/ws/');
修改为:
let socket = new WebSocket('wss://' + window.location.host + '/ws/');
vim templates/webshell/webshell.html

sock = new WebSocket('ws://' + window.location.host + '/ssh/'),
修改为:
sock = new WebSocket('wss://' + window.location.host + '/ssh/'),
@HaroldZhen
Copy link

HaroldZhen commented Nov 22, 2018

如果遇到IP連線用http,domain連線用https
建議改成以下這樣:

vim static/c_websocket.js 
let socket = new WebSocket('ws://' + window.location.host + '/ws/');
修改为:
let protocol = 'ws://';
if (window.location.protocol === 'https:') {
    protocol = 'wss://';
}
let socket = new WebSocket(protocol + window.location.host + '/ws/');
vim templates/sqlquery/sql_query.html
let socket = new WebSocket('ws://' + window.location.host + '/ws/');
修改为:
let protocol = 'ws://';
if (window.location.protocol === 'https:') {
    protocol = 'wss://';
}
let socket = new WebSocket(protocol + window.location.host + '/ws/');
vim templates/webshell/webssh.html

sock = new WebSocket('ws://' + window.location.host + '/ssh/'),
修改为:
        let protocol = 'ws://';
        if (window.location.protocol === 'https:') {
           protocol = 'wss://';
       }
        let cmd = '',
            status = '',
            sock = new WebSocket(protocol + window.location.host + '/ssh/'),

apache config

<VirtualHost *:443>
    ServerName sql.dunqian.tw

    SSLProxyEngine On
    ProxyPreserveHost On

    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/

    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://127.0.0.1:8080%{REQUEST_URI} [P]
</VirtualHost>

@lazzyfu
Copy link
Owner Author

lazzyfu commented Nov 22, 2018

感谢,代码已经merge,谢谢

@lazzyfu lazzyfu closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants