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

WebSocket and SSL certificate #215

Open
pinkynrg opened this issue Nov 19, 2019 · 6 comments
Open

WebSocket and SSL certificate #215

pinkynrg opened this issue Nov 19, 2019 · 6 comments

Comments

@pinkynrg
Copy link

I would like to solve this issue as this gentleman explains but i don't know how to do it. Any suggestions? Thanks

socketio/socket.io#1942 (comment)

@SteveLTN
Copy link
Owner

Sorry, I don't really understand what you question is.

@pinkynrg
Copy link
Author

pinkynrg commented Nov 19, 2019

I need to add this settings to the nginx that is doing the reverse proxy in order for the web sockets to work. How can I do it?

proxy_pass http://localhost:8080 ;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}

@jmayergit
Copy link

jmayergit commented Dec 11, 2019

Any updates here ?

I need to add this settings to the nginx that is doing the reverse proxy in order for the web sockets to work. How can I do it?

proxy_pass http://localhost:8080 ;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}

It looks like this is handled already meaning another solution is needed. Default nginx config ..relevent code..

    location / {
        <% if ENV['DYNAMIC_UPSTREAM'] && ENV['DYNAMIC_UPSTREAM'].downcase == 'true' %>
        set $backend <%= domain.upstream %>;
        proxy_pass $backend;
        <% else %>
        proxy_pass <%= domain.upstream %>;
        <% end %>
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        <% if ENV['WEBSOCKET'] && ENV['WEBSOCKET'].downcase == 'true' %>
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_read_timeout 2h;
        <% end %>
    }

source

@SteveLTN any ides ?

SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

Error from simple npx create-react-app

@SteveLTN
Copy link
Owner

I am not sure. As @jmayergit mentioned you can just set ‘WEBSOCK=true’ to have the headers. But why react reports error I don’t know.

@jmayergit
Copy link

I should have clarified that I'm running in a development environment. Production works as expected

@SteveLTN
Copy link
Owner

SteveLTN commented Dec 11, 2019 via email

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

3 participants