[GH-ISSUE #142] Doesn't seem to work behind reverse proxy (nginx) #115

Closed
opened 2026-02-26 05:31:22 +03:00 by kerem · 6 comments
Owner

Originally created by @ianbamforth on GitHub (Dec 16, 2014).
Original GitHub issue: https://github.com/NarrativeScience-old/log.io/issues/142

I've exposed port 28778 through nginx, but all I get is the basic web page - none of the log content is shown. Any clues what ports / routes are required in order to make it work?

Originally created by @ianbamforth on GitHub (Dec 16, 2014). Original GitHub issue: https://github.com/NarrativeScience-old/log.io/issues/142 I've exposed port 28778 through nginx, but all I get is the basic web page - none of the log content is shown. Any clues what ports / routes are required in order to make it work?
kerem closed this issue 2026-02-26 05:31:22 +03:00
Author
Owner

@tianchaijz commented on GitHub (Dec 29, 2014):

You can try this:

upstream logio {
   server 127.0.0.1:28778 max_fails=3 fail_timeout=30s;
}

location ~* /(logio|socket\.io)/ {
    rewrite ^/logio/(.*) /$1 break;

    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://logio;

    # Socket.IO Support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}                                                                                                          
<!-- gh-comment-id:68237914 --> @tianchaijz commented on GitHub (Dec 29, 2014): You can try this: ``` nginx upstream logio { server 127.0.0.1:28778 max_fails=3 fail_timeout=30s; } location ~* /(logio|socket\.io)/ { rewrite ^/logio/(.*) /$1 break; 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://logio; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } ```
Author
Owner

@denydias commented on GitHub (Apr 11, 2015):

Works like a charm!

<!-- gh-comment-id:91948071 --> @denydias commented on GitHub (Apr 11, 2015): Works like a charm!
Author
Owner

@bikashsharmabks commented on GitHub (Oct 31, 2015):

Hello,

I am trying to put log.io behind nginx server (1.8 version)
I tries out the above config but I get no response. But I do below config for nginx I get error Cannot '''

GET /logio/ 404

Here is my config

location  /logio/ {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;

          proxy_pass http://127.0.0.1:28778;

          # Socket.IO Support
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }

Anything that I am missing?

Thanks
Bikash

<!-- gh-comment-id:152723661 --> @bikashsharmabks commented on GitHub (Oct 31, 2015): Hello, I am trying to put log.io behind nginx server (1.8 version) I tries out the above config but I get no response. But I do below config for nginx I get error Cannot ''' ``` GET /logio/ 404 ``` Here is my config ``` location /logio/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://127.0.0.1:28778; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } ``` Anything that I am missing? Thanks Bikash
Author
Owner

@tkt028 commented on GitHub (Dec 25, 2016):

Hi guys,
Do we have any update for this issue? I also need to serve log.io behind nginx proxy. Thank you very much!

Cheers,
Khon

<!-- gh-comment-id:269111961 --> @tkt028 commented on GitHub (Dec 25, 2016): Hi guys, Do we have any update for this issue? I also need to serve log.io behind nginx proxy. Thank you very much! Cheers, Khon
Author
Owner

@strannik19 commented on GitHub (Mar 15, 2017):

@hajimezhao in first line, the location directive, you are missing the part for socket.io. the original example uses location ~* /(logio|socket\.io)/ to match both /logio paths (what you will be typing into the address bar) and /socket.io (the js talked to the server with this url prefix).
also, you need the rewrite rule to get rid of the logio prefix in the path when nginx fires off the requests to the logio web server running at http://127.0.0.1:28778:
rewrite ^/logio/(.*) /$1 break;
so it should look like this:

location   ~* /(logio|socket\.io)/ {
          rewrite ^/logio/(.*) /$1 break;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;

          proxy_pass http://127.0.0.1:28778;

          # Socket.IO Support
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }
<!-- gh-comment-id:286737890 --> @strannik19 commented on GitHub (Mar 15, 2017): @hajimezhao in first line, the location directive, you are missing the part for socket.io. the original example uses `location ~* /(logio|socket\.io)/` to match both /logio paths (what you will be typing into the address bar) and /socket.io (the js talked to the server with this url prefix). also, you need the rewrite rule to get rid of the logio prefix in the path when nginx fires off the requests to the logio web server running at http://127.0.0.1:28778: `rewrite ^/logio/(.*) /$1 break;` so it should look like this: ``` location ~* /(logio|socket\.io)/ { rewrite ^/logio/(.*) /$1 break; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://127.0.0.1:28778; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } ```
Author
Owner

@msmathers commented on GitHub (Jan 16, 2020):

Similar to the responses above, this nginx recipe seems to be the agreed-upon solution: https://stackoverflow.com/a/29232687

<!-- gh-comment-id:575207005 --> @msmathers commented on GitHub (Jan 16, 2020): Similar to the responses above, this nginx recipe seems to be the agreed-upon solution: https://stackoverflow.com/a/29232687
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/log.io-NarrativeScience-old#115
No description provided.