Title: [Bug]: Request to insecure websocket endpoint is blocked by browser · Issue #25040 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Request to insecure websocket endpoint is blocked by browser · Issue #25040 · matplotlib/matplotlib
X Title: [Bug]: Request to insecure websocket endpoint is blocked by browser · Issue #25040 · matplotlib/matplotlib
Description: Bug summary When running matplotlib using the webagg backend behind a reverse proxy that adds HTTPS with secure headers like HSTS, the request to the insecure websocket is blocked by the browser with the following error: Mixed Content: T...
Open Graph Description: Bug summary When running matplotlib using the webagg backend behind a reverse proxy that adds HTTPS with secure headers like HSTS, the request to the insecure websocket is blocked by the browser wi...
X Description: Bug summary When running matplotlib using the webagg backend behind a reverse proxy that adds HTTPS with secure headers like HSTS, the request to the insecure websocket is blocked by the browser wi...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/25040
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Request to insecure websocket endpoint is blocked by browser","articleBody":"### Bug summary\n\nWhen running matplotlib using the `webagg` backend behind a reverse proxy that adds HTTPS with secure headers like HSTS, the request to the insecure websocket is blocked by the browser with the following error:\r\n\r\n```\r\nMixed Content: The page at 'https:/\u003csome_website\u003e/' was loaded over HTTPS, but attempted to connect to the insecure \r\nWebSocket endpoint 'ws://\u003csome_website\u003e/1/ws'. This request has been blocked; this endpoint must be available over WSS.\r\n```\n\n### Code for reproduction\n\n```python\nimport matplotlib\r\nimport matplotlib.pyplot as plt\r\n\r\nmatplotlib.use('webagg')\r\n\r\nplt.plot(range(10))\r\nplt.show()\n```\n\n\n### Actual outcome\n\nFails to connect to the websocket with the following message:\r\n\r\n```\r\nMixed Content: The page at 'https:/\u003csome_website\u003e/' was loaded over HTTPS, but attempted to connect to the insecure \r\nWebSocket endpoint 'ws://\u003csome_website\u003e/1/ws'. This request has been blocked; this endpoint must be available over WSS.\r\n```\n\n### Expected outcome\n\nThe JavaScript code on the page should check whether the page is being served over HTTPS and if it is, the websocket uri should use `wss:` instead of `ws:`.\r\n\r\n```js\r\nvar uri = \"{{ ws_uri }}\" + {{ str(fig_id) }} + \"/ws\";\r\nif (window.location.protocol === 'https:') uri = uri.replace('ws:', 'wss:')\r\nvar websocket = new websocket_type(uri);\r\n```\n\n### Additional information\n\nYou have to be running this behind a reverse proxy that adds HTTPS and secure headers like HSTS. I'm actually running this behind a `.dev` domain. \r\n\r\nUsing Chrome\r\n\r\n\n\n### Operating system\n\nDebian\n\n### Matplotlib Version\n\n3.6.3\n\n### Matplotlib Backend\n\nwebagg\n\n### Python version\n\n3.10.1\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/whyvra","@type":"Person","name":"whyvra"},"datePublished":"2023-01-20T14:03:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/25040/matplotlib/issues/25040"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6ed26ae6-97b1-1750-31b1-e003afab069f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD12:13EE66:2405BA1:3377E5D:6A510443 |
| html-safe-nonce | 8afe675af925d6beebf40d1a5c64ae1f7b336e346095d8e67084c09e68903d17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDEyOjEzRUU2NjoyNDA1QkExOjMzNzdFNUQ6NkE1MTA0NDMiLCJ2aXNpdG9yX2lkIjoiODg4NzkzNzMwNzg5NzM3NTM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3dece28c7743634e276b56ef5d7930791f0179a47c170c5ce75fb55ad1c69b92 |
| hovercard-subject-tag | issue:1550900242 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/25040/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b635b3434f245f8ace6b90e9483be688953295911cce4e7d86e3b7a86af4dc4f/matplotlib/matplotlib/issues/25040 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b635b3434f245f8ace6b90e9483be688953295911cce4e7d86e3b7a86af4dc4f/matplotlib/matplotlib/issues/25040 |
| og:image:alt | Bug summary When running matplotlib using the webagg backend behind a reverse proxy that adds HTTPS with secure headers like HSTS, the request to the insecure websocket is blocked by the browser wi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | whyvra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 38906a4da4e3e9fd88dfeacee232f5932c0c5f7495de3b4efc53ddfac7173d12 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 90441ea9b98e7491aa6ebcd135fccce4e2396f48 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width