Update _site static files

master
Tait Hoyem 4 years ago
parent 95355fb47b
commit c5a9a56bf4

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>How to use NGINX as a reverse-proxy server for a Node.js application using socket.io | tait.tech</title>
<link rel="stylesheet" href="/assets/css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="wrapper">
<nav>
<input type="checkbox" id="menu">
<label for="menu">&#9776;</label>
<div class="menu-content">
<a href="/" class="nav-link" >Home</a>
<a href="/blog/" class="nav-link" >Blog</a>
<a href="/links/" class="nav-link" >Links</a>
<a href="/ideas/" class="nav-link" >Ideas</a>
<a href="https://github.com/TTWNO/" class="nav-link" target="_blank" rel="noopener noreferrer" >Code</a>
</div>
</nav>
<h1>How to use NGINX as a reverse-proxy server for a Node.js application using socket.io</h1>
<h4 class="post-date line-under">Friday, May 01 2020</h4>
<div class="article">
<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 nginxs <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>
</div>
<footer>
This page is mirrored on <a href="https://beta.tait.tech/2020/05/01/nginx-socket-io-projects.html">beta.tait.tech</a>.
</footer>
</div>
</body>
</html>

@ -28,6 +28,16 @@
<table class="post-list">
<tr>
<td>
<h3 class="post-title"><a class="post-title-link" href="/2020/05/01/nginx-socket-io-projects.html">How to use NGINX as a reverse-proxy server for a Node.js application using socket.io</a></h2>
<span class="post-date">01 May 2020</span>
<div class="post-excerpt"><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 nginxs <code class="highlighter-rouge">reverse_proxy</code> directive then this is the article for you!</p>
</div>
</td>
</tr>
<tr>
<td>
<h3 class="post-title"><a class="post-title-link" href="/2020/04/25/xss.html">What is XSS?</a></h2>

@ -1,4 +1,50 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.0.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2020-04-25T20:34:30+00:00</updated><id>http://localhost:4000/feed.xml</id><entry><title type="html">What is XSS?</title><link href="http://localhost:4000/2020/04/25/xss.html" rel="alternate" type="text/html" title="What is XSS?" /><published>2020-04-25T00:00:00+00:00</published><updated>2020-04-25T00:00:00+00:00</updated><id>http://localhost:4000/2020/04/25/xss</id><content type="html" xml:base="http://localhost:4000/2020/04/25/xss.html">&lt;p&gt;I found a cross-site scripting (XSS) attack
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.0.0">Jekyll</generator><link href="http://localhost:4000/feed.xml" rel="self" type="application/atom+xml" /><link href="http://localhost:4000/" rel="alternate" type="text/html" /><updated>2020-05-01T16:50:20+00:00</updated><id>http://localhost:4000/feed.xml</id><entry><title type="html">How to use NGINX as a reverse-proxy server for a Node.js application using socket.io</title><link href="http://localhost:4000/2020/05/01/nginx-socket-io-projects.html" rel="alternate" type="text/html" title="How to use NGINX as a reverse-proxy server for a Node.js application using socket.io" /><published>2020-05-01T00:00:00+00:00</published><updated>2020-05-01T00:00:00+00:00</updated><id>http://localhost:4000/2020/05/01/nginx-socket-io-projects</id><content type="html" xml:base="http://localhost:4000/2020/05/01/nginx-socket-io-projects.html">&lt;p&gt;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 nginxs &lt;code class=&quot;highlighter-rouge&quot;&gt;reverse_proxy&lt;/code&gt; directive then this is the article for you!&lt;/p&gt;
&lt;p&gt;You &lt;em&gt;must&lt;/em&gt; seperate the socket.io sockets and the static resources.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The socket connections can be routed through the default &lt;code class=&quot;highlighter-rouge&quot;&gt;$host/socket.io&lt;/code&gt; if you want to ease modifications to the source code.&lt;/li&gt;
&lt;li&gt;The connections to your main npm Node.js application can be routed through the relevant directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the relevant part of my &lt;code class=&quot;highlighter-rouge&quot;&gt;projects.tait.tech.conf&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class=&quot;terminal&quot;&gt;
location /socket.io {
proxy_pass http://localhost:8080/socket.io/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection &quot;upgrade&quot;;
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;
}
&lt;/pre&gt;
&lt;h3 id=&quot;explaination&quot;&gt;Explaination:&lt;/h3&gt;
&lt;p&gt;For this application,
I needed the &lt;code class=&quot;highlighter-rouge&quot;&gt;/ttrpg&lt;/code&gt; 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.&lt;/p&gt;
&lt;p&gt;I also needed &lt;code class=&quot;highlighter-rouge&quot;&gt;/socket.io&lt;/code&gt; to conenct to my running &lt;code class=&quot;highlighter-rouge&quot;&gt;npm&lt;/code&gt; instance.
When I tried to route all the traffic through the &lt;code class=&quot;highlighter-rouge&quot;&gt;/trrpg&lt;/code&gt; location directive
I had no luck whatsoever;
&lt;code class=&quot;highlighter-rouge&quot;&gt;$host/ttrpg/socket.io/*&lt;/code&gt; calls &lt;em&gt;always&lt;/em&gt; failed with a 404.&lt;/p&gt;
&lt;p&gt;Having two seperate blocks forwarding in different ways seems to fix this.
I am not knowledgable enough to understand how.&lt;/p&gt;
&lt;p&gt;For now, the project is alive!!!&lt;/p&gt;
&lt;p&gt;Happy hacking!&lt;/p&gt;</content><author><name></name></author><summary type="html">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 nginxs reverse_proxy directive then this is the article for you!</summary></entry><entry><title type="html">What is XSS?</title><link href="http://localhost:4000/2020/04/25/xss.html" rel="alternate" type="text/html" title="What is XSS?" /><published>2020-04-25T00:00:00+00:00</published><updated>2020-04-25T00:00:00+00:00</updated><id>http://localhost:4000/2020/04/25/xss</id><content type="html" xml:base="http://localhost:4000/2020/04/25/xss.html">&lt;p&gt;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.&lt;/p&gt;

@ -33,6 +33,10 @@
<lastmod>2020-04-25T00:00:00+00:00</lastmod>
</url>
<url>
<loc>http://localhost:4000/2020/05/01/nginx-socket-io-projects.html</loc>
<lastmod>2020-05-01T00:00:00+00:00</lastmod>
</url>
<url>
<loc>http://localhost:4000/2020-04-27-quiz-your-friends-xss.html</loc>
</url>
<url>

Loading…
Cancel
Save