Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work when using Reverse Proxy #148

Open
leonetosoft opened this issue Jun 18, 2018 · 10 comments
Open

Does not work when using Reverse Proxy #148

leonetosoft opened this issue Jun 18, 2018 · 10 comments

Comments

@leonetosoft
Copy link

Hello, I must first thank the developers for the spectacular monitoring tool.

Now I need to tell you a problem I'm having to access my metrics from an api that uses proxy.

It works as follows, my api is connected on port 5454 so I put the monitor defining the url:

 dash.attach ({
            url: '/ api / monitor'
        });
Locally worked, however external it does not bring me any monitoring data, it is empty.

My proxy works when the user types my domain name + api.

I use nginx proxy:

location / api {
                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_set_header X-NginX-Proxy true;
                proxy_pass http: // localhost: 5450;
                proxy_redirect off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $ http_upgrade;
                proxy_set_header Connection "upgrade";
        }

@sjanuary
Copy link
Contributor

I'm not that familiar with nginx but we do use web sockets to send data to the dash and the fact that you get the page loading but have empty graphs suggests that the web socket connection has failed. This page suggests that you need a capital U in upgrade for websockets:

proxy_set_header Connection "Upgrade";

@leonetosoft
Copy link
Author

leonetosoft commented Jun 18, 2018

@sjanuary That's probably it,

The dashboard is connecting to my application socket.io.
And not in the correct, I already have a socket.io running on the machine, it uses proxy:

location ~ * \ .io {
                 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_set_header X-NginX-Proxy true;
                 proxy_pass http: // localhost: 5451;
                 proxy_redirect off;
                 proxy_http_version 1.1;
                 proxy_set_header Upgrade $ http_upgrade;
                 proxy_set_header Connection "upgrade";
          }

it is connected to port 5451.
It does not work in the same app I'm using app-metrics.

soquete

How can I make both work together?

@sjanuary
Copy link
Contributor

@leonetosoft first, did you try changing proxy_set_header Connection "upgrade"; to proxy_set_header Connection "Upgrade";?

@leonetosoft
Copy link
Author

As I said,

I already have this configuration, the dashboard is connecting to my other socket server, not what it should be.

Was there something to do?

@sjanuary
Copy link
Contributor

Ok, your last post was still using a lower case 'u' in Upgrade so I assumed you hadn't changed it.
The socket shouldn't connect to a different server, it uses a specific path for appmetrics-dash - see

var socket = io.connect(hostname, { path: '/appmetrics-dash/socket.io' });
and
io = require('socket.io')(server, { path: '/appmetrics-dash/socket.io' });

@leonetosoft
Copy link
Author

Probably it should be connecting to my socket server because of this rule:

location ~* .io {
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_set_header X-NginX-Proxy true;
proxy_pass http://localhost:5451;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

She assumes ~ \ .io
That's why I watch him connect.

Would it be possible to change the socket port?

In case my uses 5451, I use proxy for any connection, from motorcycle I only keep the incoming port 80 open.

@leonetosoft
Copy link
Author

'

@leonetosoft leonetosoft reopened this Jun 26, 2018
@sjanuary
Copy link
Contributor

If you use dash.monitor rather than dash.attach then it will start appmetrics-dash in a separate server on its own port. I imagine you could then define two rules for your proxy, one for your application and one for appmetrics and different ports for each?

@leonetosoft
Copy link
Author

I understand, using the monitor (options) is it possible to change the port that Socket.IO works?

Am I right ?

options.server = my express server, http
options.port = SocketIO Port?

Thanks for listening.

@sjanuary
Copy link
Contributor

sjanuary commented Jun 28, 2018

No, you can configure the port but not alongside setting the server option (edited)

See https://github.com/RuntimeTools/appmetrics-dash#monitoroptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants