Nginx Reverse Proxy Config - 404 Not Found

I have deployed a react app on a remote server (digital ocean), and I want to be able to access the localhost of the server from the react app client-side.

I have tried setting up a reverse proxy with Nginx, however I am getting an awful 404.

The site is deployed, The problem occurs under the game sections when you choose either rock, scissor or paper and then the button to fight the AI.

This is my sites-enabled inside of the Nginx

server {
  root /var/www/;
  index index.html;
  location / {
    try_files $uri $uri/ =404;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed b$
    ssl_certificate_key /etc/letsencrypt/live/; # managed$
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /game {
        rewrite /game/(.*)  /$1 break;
        proxy_pass http://localhost:1234;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
server {
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot
  listen 80 default_server;
  listen [::]:80 default_server;
    return 404; # managed by Certbot

this is the port and path the node.js express service is listening on:

app.listen(PORT,  function(){
console.log(`listening on port:${PORT}...`)

app.get("/game/play/:choice", function(req,res){
    pythonProcess = spawn('python',["./", req.params.choice]);
    pythonProcess.stdout.on('data', function(data) {

this is how i fetch from the react app


Is the problem to detect, because I am slowly losing my sanity.


I have tried on both


which yields this error message: Game.js:46 GET 404 (Not Found)

and fetch("")

which yields this error message:

Game.js:46 GET 404 (Not Found)

Trying to access it with postman through 

gives following error message:

        <title>404 Not Found</title>
    <body bgcolor="white">
            <h1>404 Not Found</h1>
        <center>nginx/1.14.0 (Ubuntu)</center>


The issue is that you're using the IP address instead of the domain you have set on server_name directive. So instead of using that site configuration, it's going to the default Nginx configuration.



You can also drop:

    rewrite /game/(.*)  /$1 break;