<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Colyseus and wss proxy (to a docker)]]></title><description><![CDATA[<p>Installing Local Certificate Authority for testing purposes.</p>
<p>I wanted to create a proxy from wss to ws connection. But I didn't want to touch my production environment.</p>
<p>So I created a local certificate authority on my local = private computer.</p>
<p>This is how I did this (Oracle Enterprise Linux = CentOS = RedHat - based)</p>
<p>(First start with a root login)</p>
<ul>
<li>vi /etc/yum/repos.d/epel-yum-ol7.repo</li>
</ul>
<pre><code>[ol7_epel]
name=Oracle Linux $releasever EPEL ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
</code></pre>
<ul>
<li>
<p>yum repolist</p>
</li>
<li>
<p>yum -y install easy-rsa</p>
</li>
</ul>
<p>Connect non-root-user</p>
<ul>
<li>
<p>useradd myrsa</p>
</li>
<li>
<p>passwd myrsa</p>
</li>
<li>
<p>su - myrsa</p>
</li>
</ul>
<p>(add user to sudoers)</p>
<ul>
<li>
<p>mkdir ~/easy-rsa</p>
</li>
<li>
<p>ln -s /usr/share/easy-rsa/3/* ~/easy-rsa/</p>
</li>
<li>
<p>chmod 700 ~/easy-rsa</p>
</li>
<li>
<p>cd ~/easy-rsa<br />
*./easyrsa init-pki</p>
</li>
<li>
<p>vi vars</p>
</li>
</ul>
<pre><code>set_var EASYRSA_REQ_COUNTRY    &quot;NL&quot;
set_var EASYRSA_REQ_PROVINCE   &quot;MyProv&quot;
set_var EASYRSA_REQ_CITY       &quot;MyCity&quot;
set_var EASYRSA_REQ_ORG        &quot;MyOrg&quot;
set_var EASYRSA_REQ_EMAIL      &quot;admin@localhost&quot;
set_var EASYRSA_REQ_OU         &quot;Community&quot;
set_var EASYRSA_ALGO           &quot;ec&quot;
set_var EASYRSA_DIGEST         &quot;sha512&quot;
</code></pre>
<ul>
<li>./easyrsa build-ca nopass</li>
</ul>
<pre><code>. . .
Enter New CA Key Passphrase:
Re-Enter New CA Key Passphrase:
. . .
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
~/easy-rsa/pki/ca.crt
</code></pre>
<ul>
<li>cat ~/easy-rsa/pki/ca.crt</li>
</ul>
<hr />
<p>Other Server : WebServer  (or the same system : in my case the same system )</p>
<ul>
<li>
<p>vi /tmp/ca.crt<br />
pate data from the ca.crt you created earlier</p>
</li>
<li>
<p>sudo cp /tmp/ca.crt /etc/pki/ca-trust/source/anchors/</p>
</li>
<li>
<p>sudo update-ca-trust</p>
</li>
</ul>
<p>Make private key</p>
<ul>
<li>openssl genrsa -out webserver.key</li>
</ul>
<p>Certificate SIGNING request : CSR</p>
<ul>
<li>openssl req -new -key webserver.key -out webserver.req</li>
</ul>
<p>Verify:</p>
<ul>
<li>
<p>openssl req -in webserver.req -noout -subject</p>
</li>
<li>
<p>cat webserver.req<br />
-----BEGIN CERTIFICATE REQUEST-----<br />
....</p>
</li>
</ul>
<p>Transport this certificate to the ca-server</p>
<ul>
<li>vi /tmp/webserver.req<br />
paste - webserver.req from other server</li>
</ul>
<ul>
<li>cd ~/easy-rsa</li>
<li>./easyrsa import-req /tmp/webserver.req webserver</li>
<li>./easyrsa sign-req server webserver<br />
Enter: Yes</li>
</ul>
<p>Certificate created at: .../webserver.crt</p>
<ul>
<li>cat ~/easy-rsa/pki/issued/webserver.crt</li>
</ul>
<p>-----BEGIN CERTIFICATE-----</p>
<p>Take this certifcate to the webserver</p>
<ul>
<li>vi /tmp/webserver_ca.crt<br />
Paste certificate</li>
</ul>
<p>WebServer (root)</p>
<ul>
<li>cp /tmp/webserver_ca.crt /etc/pki/tls/certs/webserver_ca.crt</li>
<li>cp webserver.key /etc/pki/tls/private/webserver.key</li>
<li>chmod 600 /etc/pki/tls/private/webserver.key</li>
</ul>
<ul>
<li>yum -y install httpd mod_ssl mod_dav_svn ssl proxy proxy_http proxy_html proxy_wstunne</li>
<li>vi /etc/httpd/conf.d/ssl.conf</li>
</ul>
<p>SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt<br />
SSLCertificateKeyFile /etc/pki/tls/private/webserver.key<br />
SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt</p>
<p>service httpd restart</p>
<p>Importing CA in Browser</p>
<p>In order for the client to trust the server it should also trust the CA that made the key.</p>
<p>Generate a key you can import in a browser:</p>
<ul>
<li>cd /home/myrsa/easy-rsa</li>
<li>openssl pkcs12 -export -in pki/ca.crt -inkey  pki/private/ca.key -out browser.pfx</li>
</ul>
<hr />
<p>Browser / Client</p>
<p>Client computer:<br />
c&gt; pscp root@ca_server:/home/myrsa/easy-rsa/browser.pfx Downloads</p>
<p>Add the name 'webserver' to your host-resolver:</p>
<p>C&gt; notepad c:\windows\system32\drivers\etc\hosts<br />
192.168.0.12 webserver</p>
<p>Open browser</p>
<ul>
<li>chrome://settings/security?search=certificat<br />
Go to certificate management and import the PFX into the Trusted ROOT CERTIFICATES</li>
</ul>
<p>You can now make a secure connection to the webserver:</p>
<p><a href="https://webserver" rel="nofollow">https://webserver</a></p>
<p><strong>Proxy Forward</strong></p>
<ul>
<li>vi /etc/httpd/conf.d/ssl.conf<br />
Add below  in the file :</li>
</ul>
<p>To make sure that all non-browser traffic goes to specific port I open up the 8567 port instead of 443</p>
<pre><code>  &lt;VirtualHost *:8567&gt;
    
    SSLEngine On
    SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/webserver.key
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt

     RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
        # Port 3567 is where the docker is listening for
    RewriteRule ^/(.*)    ws://0.0.0.0:3567/$1 [P,L]

  &lt;/VirtualHost&gt;
</code></pre>
<p>My docker is started like this:</p>
<ul>
<li>docker run --name=col -h col --dns=8.8.8.8 -p 3567:3567  -v /home/root:/home/extern/ -t -d oel /bin/bash</li>
</ul>
<p>Port forward trafic comming from 3567 is going inside the docker where colyseus is listening on 3567 as well.</p>
<p>Firewall is completely open on my private server.<br />
This should never be done for global servers. But for global servers you really need a non-self-signed certificate.</p>
<p>You now have a secure connection to the server and it will proxy the stream to the docker. Inside the docker (colyseus-code) nothing has to be altered!</p>
]]></description><link>http://discuss.colyseus.io/topic/461/colyseus-and-wss-proxy-to-a-docker</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 20:04:11 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/461.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Apr 2021 15:48:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Colyseus and wss proxy (to a docker) on Invalid Date]]></title><description><![CDATA[<p>Installing Local Certificate Authority for testing purposes.</p>
<p>I wanted to create a proxy from wss to ws connection. But I didn't want to touch my production environment.</p>
<p>So I created a local certificate authority on my local = private computer.</p>
<p>This is how I did this (Oracle Enterprise Linux = CentOS = RedHat - based)</p>
<p>(First start with a root login)</p>
<ul>
<li>vi /etc/yum/repos.d/epel-yum-ol7.repo</li>
</ul>
<pre><code>[ol7_epel]
name=Oracle Linux $releasever EPEL ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
</code></pre>
<ul>
<li>
<p>yum repolist</p>
</li>
<li>
<p>yum -y install easy-rsa</p>
</li>
</ul>
<p>Connect non-root-user</p>
<ul>
<li>
<p>useradd myrsa</p>
</li>
<li>
<p>passwd myrsa</p>
</li>
<li>
<p>su - myrsa</p>
</li>
</ul>
<p>(add user to sudoers)</p>
<ul>
<li>
<p>mkdir ~/easy-rsa</p>
</li>
<li>
<p>ln -s /usr/share/easy-rsa/3/* ~/easy-rsa/</p>
</li>
<li>
<p>chmod 700 ~/easy-rsa</p>
</li>
<li>
<p>cd ~/easy-rsa<br />
*./easyrsa init-pki</p>
</li>
<li>
<p>vi vars</p>
</li>
</ul>
<pre><code>set_var EASYRSA_REQ_COUNTRY    &quot;NL&quot;
set_var EASYRSA_REQ_PROVINCE   &quot;MyProv&quot;
set_var EASYRSA_REQ_CITY       &quot;MyCity&quot;
set_var EASYRSA_REQ_ORG        &quot;MyOrg&quot;
set_var EASYRSA_REQ_EMAIL      &quot;admin@localhost&quot;
set_var EASYRSA_REQ_OU         &quot;Community&quot;
set_var EASYRSA_ALGO           &quot;ec&quot;
set_var EASYRSA_DIGEST         &quot;sha512&quot;
</code></pre>
<ul>
<li>./easyrsa build-ca nopass</li>
</ul>
<pre><code>. . .
Enter New CA Key Passphrase:
Re-Enter New CA Key Passphrase:
. . .
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
~/easy-rsa/pki/ca.crt
</code></pre>
<ul>
<li>cat ~/easy-rsa/pki/ca.crt</li>
</ul>
<hr />
<p>Other Server : WebServer  (or the same system : in my case the same system )</p>
<ul>
<li>
<p>vi /tmp/ca.crt<br />
pate data from the ca.crt you created earlier</p>
</li>
<li>
<p>sudo cp /tmp/ca.crt /etc/pki/ca-trust/source/anchors/</p>
</li>
<li>
<p>sudo update-ca-trust</p>
</li>
</ul>
<p>Make private key</p>
<ul>
<li>openssl genrsa -out webserver.key</li>
</ul>
<p>Certificate SIGNING request : CSR</p>
<ul>
<li>openssl req -new -key webserver.key -out webserver.req</li>
</ul>
<p>Verify:</p>
<ul>
<li>
<p>openssl req -in webserver.req -noout -subject</p>
</li>
<li>
<p>cat webserver.req<br />
-----BEGIN CERTIFICATE REQUEST-----<br />
....</p>
</li>
</ul>
<p>Transport this certificate to the ca-server</p>
<ul>
<li>vi /tmp/webserver.req<br />
paste - webserver.req from other server</li>
</ul>
<ul>
<li>cd ~/easy-rsa</li>
<li>./easyrsa import-req /tmp/webserver.req webserver</li>
<li>./easyrsa sign-req server webserver<br />
Enter: Yes</li>
</ul>
<p>Certificate created at: .../webserver.crt</p>
<ul>
<li>cat ~/easy-rsa/pki/issued/webserver.crt</li>
</ul>
<p>-----BEGIN CERTIFICATE-----</p>
<p>Take this certifcate to the webserver</p>
<ul>
<li>vi /tmp/webserver_ca.crt<br />
Paste certificate</li>
</ul>
<p>WebServer (root)</p>
<ul>
<li>cp /tmp/webserver_ca.crt /etc/pki/tls/certs/webserver_ca.crt</li>
<li>cp webserver.key /etc/pki/tls/private/webserver.key</li>
<li>chmod 600 /etc/pki/tls/private/webserver.key</li>
</ul>
<ul>
<li>yum -y install httpd mod_ssl mod_dav_svn ssl proxy proxy_http proxy_html proxy_wstunne</li>
<li>vi /etc/httpd/conf.d/ssl.conf</li>
</ul>
<p>SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt<br />
SSLCertificateKeyFile /etc/pki/tls/private/webserver.key<br />
SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt</p>
<p>service httpd restart</p>
<p>Importing CA in Browser</p>
<p>In order for the client to trust the server it should also trust the CA that made the key.</p>
<p>Generate a key you can import in a browser:</p>
<ul>
<li>cd /home/myrsa/easy-rsa</li>
<li>openssl pkcs12 -export -in pki/ca.crt -inkey  pki/private/ca.key -out browser.pfx</li>
</ul>
<hr />
<p>Browser / Client</p>
<p>Client computer:<br />
c&gt; pscp root@ca_server:/home/myrsa/easy-rsa/browser.pfx Downloads</p>
<p>Add the name 'webserver' to your host-resolver:</p>
<p>C&gt; notepad c:\windows\system32\drivers\etc\hosts<br />
192.168.0.12 webserver</p>
<p>Open browser</p>
<ul>
<li>chrome://settings/security?search=certificat<br />
Go to certificate management and import the PFX into the Trusted ROOT CERTIFICATES</li>
</ul>
<p>You can now make a secure connection to the webserver:</p>
<p><a href="https://webserver" rel="nofollow">https://webserver</a></p>
<p><strong>Proxy Forward</strong></p>
<ul>
<li>vi /etc/httpd/conf.d/ssl.conf<br />
Add below  in the file :</li>
</ul>
<p>To make sure that all non-browser traffic goes to specific port I open up the 8567 port instead of 443</p>
<pre><code>  &lt;VirtualHost *:8567&gt;
    
    SSLEngine On
    SSLCertificateFile /etc/pki/tls/certs/webserver_ca.crt
    SSLCertificateKeyFile /etc/pki/tls/private/webserver.key
    SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt

     RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
        # Port 3567 is where the docker is listening for
    RewriteRule ^/(.*)    ws://0.0.0.0:3567/$1 [P,L]

  &lt;/VirtualHost&gt;
</code></pre>
<p>My docker is started like this:</p>
<ul>
<li>docker run --name=col -h col --dns=8.8.8.8 -p 3567:3567  -v /home/root:/home/extern/ -t -d oel /bin/bash</li>
</ul>
<p>Port forward trafic comming from 3567 is going inside the docker where colyseus is listening on 3567 as well.</p>
<p>Firewall is completely open on my private server.<br />
This should never be done for global servers. But for global servers you really need a non-self-signed certificate.</p>
<p>You now have a secure connection to the server and it will proxy the stream to the docker. Inside the docker (colyseus-code) nothing has to be altered!</p>
]]></description><link>http://discuss.colyseus.io/post/1488</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1488</guid><dc:creator><![CDATA[mdotedot]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>