diff --git a/client/client.py b/client/client.py index 310abefc3b1c2e27f1c7d64007d6f1cddfd90fea..36739e14421feca0fbfac5efe3ad72b4230d111a 100755 --- a/client/client.py +++ b/client/client.py @@ -112,7 +112,7 @@ Relays command from the server to the mpv instance, but sanitizes the commands." ) parser.add_argument( - "--port", help="The port of the server.", default=8432, type=int + "--port", help="The port of the server.", default=443, type=int ) parser.add_argument("--ca-file", help="Path to the certicate file.", required=False) @@ -202,7 +202,9 @@ async def handle_server(hostname, port, group, ignore_cert): if ignore_cert: ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE - uri = f"wss://{hostname}:{port}/{group}" + + uri = f"wss://{hostname}/api/ws/{group}" + while True: try: async with websockets.connect(uri, ssl=ssl_context) as ws: diff --git a/frontend/src/store/store.ts b/frontend/src/store/store.ts index b6d0f2da0d0666adbcdefbf4f7b1187fb54805b8..7a853527466dbc8346ce344e52be05793f82b8f3 100644 --- a/frontend/src/store/store.ts +++ b/frontend/src/store/store.ts @@ -57,8 +57,17 @@ export const store = configureStore({ ], }); -const path = window.location.pathname; -store.dispatch(connect("wss://mpvsync.de:8432/" + path)); +const domain = window.location.hostname; +const group = window.location.pathname; + +let ws_url = `wss://${domain}/api/ws/${group}` + +// It's localhost, no SSL needed / possible. +if(domain === 'localhost'){ + ws_url = `ws://${domain}:8432/${group}` +} + +store.dispatch(connect(ws_url)); sagaMiddleware.run(rootSaga); export type RootState = ReturnType<typeof store.getState>; diff --git a/frontend/src/url/InputBar.tsx b/frontend/src/url/InputBar.tsx index 3fad070a659314d5159796d6081f3b3834220c38..bd35e845ed2b8f50a9b87ad90dad2a5ff7a34dcc 100644 --- a/frontend/src/url/InputBar.tsx +++ b/frontend/src/url/InputBar.tsx @@ -51,8 +51,8 @@ class UrlBox extends React.Component<Props> { } handleServerClick(): void | undefined { - this.props.dispatchUrl("https://mpvsync.de/video/index.mp4"); - this.props.dispatchSubtitleFile("https://mpvsync.de/video/index.vtt"); + this.props.dispatchUrl("/video/index.mp4"); + this.props.dispatchSubtitleFile("/video/index.vtt"); } async handleSubtitleClick(): Promise<void | undefined> { diff --git a/mpvsync.conf b/mpvsync.conf new file mode 100644 index 0000000000000000000000000000000000000000..8260fb5fe9baa97f921f855deb5969b82c7f32b9 --- /dev/null +++ b/mpvsync.conf @@ -0,0 +1,33 @@ +server { + + # TODO CHANGE :) + server_name your_servername.com; + + listen 443 ssl; # managed by Certbot + listen [::]:443 ssl; # managed by Certbot + + ssl_session_timeout 5m; + ssl_protocols SSLv2 SSLv3 TLSv1; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + + location / { + proxy_pass http://127.0.0.1:8430; + } + + location /api/ws/ { + proxy_pass http://127.0.0.1:8432/; + + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + + # TODO CHANGE :) + ssl_certificate /path/to/your/fullchain.pem # Can be managed by Certbot + ssl_certificate_key /path/to/your/certificate_key.pem # Can be managed by Certbot +}