webssh icon indicating copy to clipboard operation
webssh copied to clipboard

Cross origin operation is not allowed.

Open chenlhcodes opened this issue 4 years ago • 6 comments

我在使用nginx将本地的webssh转发出去后,访问代理地址,连接报错:Cross origin operation is not allowed. 请问怎么解决呢

chenlhcodes avatar Nov 03 '20 04:11 chenlhcodes

我也遇到相同的问题了,不过我用nginx代理可以使用,但是用apache服务器代理就会报Cross origin operation is not allowed.

hp525350557 avatar Nov 05 '20 09:11 hp525350557

Exact same error here

rambip avatar Apr 19 '21 21:04 rambip

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 !

rambip avatar Apr 20 '21 12:04 rambip

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;
        }

muxi01 avatar May 15 '21 07:05 muxi01

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;
		}

bode135 avatar Jan 12 '23 09:01 bode135