webssh
webssh copied to clipboard
Cross origin operation is not allowed.
我在使用nginx将本地的webssh转发出去后,访问代理地址,连接报错:Cross origin operation is not allowed. 请问怎么解决呢
我也遇到相同的问题了,不过我用nginx代理可以使用,但是用apache服务器代理就会报Cross origin operation is not allowed.
Exact same error here
I found the config that worked for me with nginx:
server {
listen 80;
location /ssh/ {
proxy_pass http://localhost:8888/;
proxy_set_header Host $http_host;
proxy_read_timeout 300;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
}
}
For wssh to work with a reverse proxy, make sure the adress is /ssh/
and the proxy_pass is http://localhost:8888/
: all the slashes are important here.
Then, make sure you use add the header proxy_set_header Host $http_host
to indicate the right host adress to wssh.
Maybe the X-forwarded-for header could work here, I didn't test it.
I hope this can be usefull to somebody !
i apply the same config as your,it working on only http model, but not good for https.
location /wssh/ {
proxy_pass http://127.0.0.1:9000/;
proxy_set_header Host $http_host;
proxy_read_timeout 300;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
}
I use those, it's successful to visit the login webpage.
but i can't login by nginx's proxy url while i can login use the direct ip:port url.
then i found it should add the proxy_http_version 1.1;
.
like these:
location /api/webssh/ {
proxy_pass http://localhost:28000/;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_read_timeout 300;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
}