Issue with Nginx and graylog

Hello dear community,

I’m setting up a graylog as a demo server for my company.

I first tested the thing with no reverse proxy and with the following configuration in server.conf

rest_listen_uri = my lan ip:9000/api
web_listen_uri = my lan ip:9000/

It worked like a charm.

I wanted something more complex : separate api and web ports, and use nginx.

I switched to this :

Nginx :

server

{
    listen 80 default_server;
    server_name 192.168.41.68;

access_log      /var/log/nginx/graylog.access.log;

location / {

        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Graylog-Server-URL http://192.168.41.68/api;
        proxy_pass http://127.0.0.1:9000;
        }

location /api/ {

        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:12900/;
        }
}

and this in server.conf : web_listen_uri and web_endpoint_uri commented.

rest_listen_uri = http://127.0.0.1:12900/api/
rest_transport_uri = http://192.168.41.68:12900/api/

I get a 404 :

Error message
cannot GET http://192.168.41.68/api/ (404)

I’m out of ideas … Do you have something in mind ?

I would recommend the following Documentation:

http://docs.graylog.org/en/2.4/pages/configuration/web_interface.html#making-the-web-interface-work-with-load-balancers-proxies

Why not using your very first settings with nginx?

I kept the same nginx settings and followed your advice.

except for this in nginx :

location /api/ {

        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:9000/;

I used this :

rest_listen_uri = 127.0.0.1:9000/api
web_listen_uri = 127.0.0.1:9000/ 

Im getting a 404 but I’m allowed to get to the login page and try to login :slight_smile:

error :

Error - the server returned: 404 - cannot POST http://192.168.41.68/api/system/sessions (404)

Ok this is solved by using your recommendations but what I wanted was to be able to use nginx and differents ports for interface and api.

Whatever works : it is a demo after all.

Thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.