Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:52:27+00:00 2026-06-18T09:52:27+00:00

I’m working on a fully js, HTML5 canvas game and want it to be

  • 0

I’m working on a fully js, HTML5 canvas game and want it to be ‘real-time’. Based on my research I find out node.js is an exciting prospect, so I configured it on my ubuntu 12 webserver with socket.io, express etc.

I’m a programmer, but just a rookie in the world of webserver backends, that’s why I ask for your help. I got confused about the overall system model and want to be clarified how it’s working. Maybe, I’ve read too much article in a short time.

First of all: I run nginx 1.2.x on my webserver. As I know, nginx is handling the rquests, it’s dedicated to port 80 (for me) and serving http requests (also using php-fpm to serve php).
Then again, I have a succesfully running nodejs server on port 8080. I want the connection via websocket (due it’s nature and protocol), since nginx not support websocket yet I got confused about what’s going on.

If I go to http//mydomain.tld:8080, is this going to through node server and keep off nginx? In this case the connection could be via websocket and not falling back to xhr or anything else (i dont want it, because of scalability), right?

Then what should i do to have the same effect at http//mydomain.tld/game/ ? Just proxy the request in nginx.conf to node server? Like:

 # if a file does not exist in the specified root and nothing else is definded, we want to serve the request via node.js
try_files   $uri    @nodejs;          

location @nodejs
{       
     proxy_pass  127.0.0.1:8080;
     break;
}

From: https://stackoverflow.com/a/14025374/2039342

And if it is a good proxy workaround when we need the websocket communication via nginx? Do we when we want a regular php site and socket.io connection inside it. By this time I presume the point is to run the traffic on port 80 and separate standard requests and websocket traffic. In my case what is the simpliest solution?

http://www.exratione.com/2012/07/proxying-websocket-traffic-for-nodejs-the-present-state-of-play/ in this article i found out HAProxy could be the one for me till nginx 1.3, is it?

I know my questions are a bit chaotic, but I’m straggling to understand the exact technik. Please give me some hint | article to read | starting point | basic config.

PS.: I’ve read the most of the related topics here.

Ps2.: to look less dumb: I’ve already done this game in red5 (java based flash server) + flash, so I just want to reconsider and publish it with proper current technologies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:52:28+00:00Added an answer on June 18, 2026 at 9:52 am

    Finally, my basic problem was configuring the nginx in the right way.

    First I reinstalled nginx as a patched version with nginx_tcp_proxy_module.

    The next step was setting up the right config to handle requests: via http or tcp.
    I wanted the standard files to be served normally from webroot, just the game logic by node.js (and the socket.io js itself ofc) and .php files by php_fpm.

    So I ended up with the following working nginx setup:

    user  www-data;
    worker_processes  16;
    
    events {
        worker_connections  1024;
    }
    
    http {
        upstream node-js-myapp {
            server 127.0.0.1:3000;
        }
    
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
        keepalive_timeout  65;
        gzip  on;
    
        server {
            listen          80;
            server_name    domain.xx;  # Multiple hostnames seperated by spaces
            root            /var/www/domain.xx; # Replace this
            charset         utf-8;
            access_log  /var/log/nginx/domain.xx.access.log  combined;
            error_log   /var/log/nginx/domain.xx.error.log;
    
            location ~ \.php$ {
                    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name; 
                    include /etc/nginx/conf.d/php_fpm; # Includes config for PHP-FPM (see below)
            }
    
    
            location / {
                index  index.html index.htm;
            }
    
    
            location ^~ /socket.io/ {
                try_files $uri @node-js-myapp;
            }
    
            location /status {
                check_status;
            }
    
            location @node-js-myapp { 
              proxy_set_header X-Real-IP  $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $http_host;
              proxy_pass  http://node-js-myapp;
            }
        }
    }
    
    tcp {
      upstream websocket-myapp {
        server 127.0.0.1:8080;
        check interval=3000 rise=2 fall=5 timeout=1000;
      }
    
      server {
        listen 3000;
        server_name _;
        access_log  /var/log/nginx/domain.xx.access.log;
    
        proxy_read_timeout 200000;
        proxy_send_timeout 200000;
        proxy_pass websocket-myapp;
      }
    }
    

    It’s working well with this node.js server:

    var app = require('express').createServer()
    var io = require('socket.io').listen(app);
    io.set('transports', [
        'websocket'
      , 'flashsocket'
      , 'htmlfile'
      , 'xhr-polling'
      , 'jsonp-polling'
      ]);
    
    app.listen(8080);
    

    While the requested file is in the public side of my server and in its HEAD section:

    <script src="/socket.io/socket.io.js"></script>
    

    I’m pretty sure my nginx is not complete and could contain bulls…, but it’s kind of working and a good starting point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.