huashengdun / webssh

:seedling: Web based ssh client
https://webssh.huashengdun.org/
MIT License
4.5k stars 1.28k forks source link

Cross origin operation is not allowed. #163

Open shelbyKiraM opened 4 years ago

shelbyKiraM commented 4 years ago

When I try to click connect I get Cross origin operation is not allowed. in div.status? My server is set up not to allow cross origin scripts… I'm accessing the page through an NGINX proxy at https://ssh.example.com, as http://example.com:8888 doesn't load (prob due to something not working with my Cloudflare setup but also because I have HSTS set up so it has to be SSL).

Any thoughts? Maybe we need to rewrite the URL it's asking for the scripts from?

chenlhcodes commented 3 years ago

Hello, I met the same problem with you. Have you solved the problem?

rambip commented 3 years ago

Same error here. I think this is a nginx problem: The first time I used an almost empty config and that worked. Now I want to set it up on location /ssh/ of my server. Could that be related ?

rambip commented 3 years ago

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 !

xiaoquisme commented 1 month ago

I fix it by run cmd: python main.py --origin=* --debug