From c5a9a56bf4680b2b5d0f39de93862d958a5dfe8c Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Fri, 1 May 2020 16:52:29 +0000 Subject: [PATCH] Update _site static files --- .../2020/05/01/nginx-socket-io-projects.html | 90 +++++++++++++++++++ _site/blog/index.html | 10 +++ _site/feed.xml | 48 +++++++++- _site/sitemap.xml | 4 + 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 _site/2020/05/01/nginx-socket-io-projects.html diff --git a/_site/2020/05/01/nginx-socket-io-projects.html b/_site/2020/05/01/nginx-socket-io-projects.html new file mode 100644 index 0000000..21001c4 --- /dev/null +++ b/_site/2020/05/01/nginx-socket-io-projects.html @@ -0,0 +1,90 @@ + + + + + How to use NGINX as a reverse-proxy server for a Node.js application using socket.io | tait.tech + + + + +
+ + +

How to use NGINX as a reverse-proxy server for a Node.js application using socket.io

+ + +
+

Despite the long name of the article, I have a feeling this may apply to more people than I might think. +If you have a Node.js application which needs socket.io connections that you want to pass throgh nginx’s reverse_proxy directive then this is the article for you!

+ +

You must seperate the socket.io sockets and the static resources.

+ +
    +
  • The socket connections can be routed through the default $host/socket.io if you want to ease modifications to the source code.
  • +
  • The connections to your main npm Node.js application can be routed through the relevant directory.
  • +
+ +

Here is the relevant part of my projects.tait.tech.conf file:

+ +
+location /socket.io {
+  proxy_pass http://localhost:8080/socket.io/;
+  proxy_set_header Upgrade $http_upgrade;
+  proxy_set_header Connection "upgrade";
+  proxy_http_version 1.1;
+  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+  proxy_set_header Host $host;
+}
+
+location /ttrpg {
+  proxy_pass http://localhost:8080/;
+  proxy_set_header Host $host;
+  proxy_set_header X-Real-IP $remote_addr;
+  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+}
+
+ +

Explaination:

+ +

For this application, +I needed the /ttrpg directory to connect to my main Node.js instance. This was going to be the root of a ttrpg project. +It was to have static files served form my Node.js application.

+ +

I also needed /socket.io to conenct to my running npm instance. +When I tried to route all the traffic through the /trrpg location directive +I had no luck whatsoever; +$host/ttrpg/socket.io/* calls always failed with a 404.

+ +

Having two seperate blocks forwarding in different ways seems to fix this. +I am not knowledgable enough to understand how.

+ +

For now, the project is alive!!!

+ +

Happy hacking!

+ + +
+ + + +
+ + diff --git a/_site/blog/index.html b/_site/blog/index.html index ed2d237..7eb6649 100644 --- a/_site/blog/index.html +++ b/_site/blog/index.html @@ -28,6 +28,16 @@ + + + +
+

How to use NGINX as a reverse-proxy server for a Node.js application using socket.io

+ +

Despite the long name of the article, I have a feeling this may apply to more people than I might think. +If you have a Node.js application which needs socket.io connections that you want to pass throgh nginx’s reverse_proxy directive then this is the article for you!

+
+

What is XSS?

diff --git a/_site/feed.xml b/_site/feed.xml index 7d794f3..3ea034b 100644 --- a/_site/feed.xml +++ b/_site/feed.xml @@ -1,4 +1,50 @@ -Jekyll2020-04-25T20:34:30+00:00http://localhost:4000/feed.xmlWhat is XSS?2020-04-25T00:00:00+00:002020-04-25T00:00:00+00:00http://localhost:4000/2020/04/25/xss<p>I found a cross-site scripting (XSS) attack +Jekyll2020-05-01T16:50:20+00:00http://localhost:4000/feed.xmlHow to use NGINX as a reverse-proxy server for a Node.js application using socket.io2020-05-01T00:00:00+00:002020-05-01T00:00:00+00:00http://localhost:4000/2020/05/01/nginx-socket-io-projects<p>Despite the long name of the article, I have a feeling this may apply to more people than I might think. +If you have a Node.js application which needs socket.io connections that you want to pass throgh nginx’s <code class="highlighter-rouge">reverse_proxy</code> directive then this is the article for you!</p> + +<p>You <em>must</em> seperate the socket.io sockets and the static resources.</p> + +<ul> + <li>The socket connections can be routed through the default <code class="highlighter-rouge">$host/socket.io</code> if you want to ease modifications to the source code.</li> + <li>The connections to your main npm Node.js application can be routed through the relevant directory.</li> +</ul> + +<p>Here is the relevant part of my <code class="highlighter-rouge">projects.tait.tech.conf</code> file:</p> + +<pre class="terminal"> +location /socket.io { + proxy_pass http://localhost:8080/socket.io/; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; +} + +location /ttrpg { + proxy_pass http://localhost:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +} +</pre> + +<h3 id="explaination">Explaination:</h3> + +<p>For this application, +I needed the <code class="highlighter-rouge">/ttrpg</code> directory to connect to my main Node.js instance. This was going to be the root of a ttrpg project. +It was to have static files served form my Node.js application.</p> + +<p>I also needed <code class="highlighter-rouge">/socket.io</code> to conenct to my running <code class="highlighter-rouge">npm</code> instance. +When I tried to route all the traffic through the <code class="highlighter-rouge">/trrpg</code> location directive +I had no luck whatsoever; +<code class="highlighter-rouge">$host/ttrpg/socket.io/*</code> calls <em>always</em> failed with a 404.</p> + +<p>Having two seperate blocks forwarding in different ways seems to fix this. +I am not knowledgable enough to understand how.</p> + +<p>For now, the project is alive!!!</p> + +<p>Happy hacking!</p>Despite the long name of the article, I have a feeling this may apply to more people than I might think. If you have a Node.js application which needs socket.io connections that you want to pass throgh nginx’s reverse_proxy directive then this is the article for you!What is XSS?2020-04-25T00:00:00+00:002020-04-25T00:00:00+00:00http://localhost:4000/2020/04/25/xss<p>I found a cross-site scripting (XSS) attack in a well-known quiz hosting website. I disclosed the vulnerability to them years ago, so I thought now might be a good time to write about it.</p> diff --git a/_site/sitemap.xml b/_site/sitemap.xml index dd819bb..b923cbf 100644 --- a/_site/sitemap.xml +++ b/_site/sitemap.xml @@ -33,6 +33,10 @@ 2020-04-25T00:00:00+00:00 +http://localhost:4000/2020/05/01/nginx-socket-io-projects.html +2020-05-01T00:00:00+00:00 + + http://localhost:4000/2020-04-27-quiz-your-friends-xss.html