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

confusing nginx.conf docs example; use both ngx_http_subs_filter_module and ngx_http_sub_module #2675

Open
jtmoon79 opened this issue Jul 9, 2022 · 1 comment

Comments

@jtmoon79
Copy link

jtmoon79 commented Jul 9, 2022

tl;dr docs allude to two different nginx modules ngx_http_subs_filter_module and ngx_http_sub_module.


The documentation example nginx.conf is

server {
    listen gerbera.DOMAINNAME:80;
    server_name gerbera.DOMAINNAME;

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

        # install sub filter module and enable in nginx.conf
        # load_module /usr/lib64/nginx/modules/ngx_http_subs_filter_module.so;
        sub_filter_once    off;
        sub_filter_types   text/html application/json;
        sub_filter         'http://GERBERA_IP:GERBERA_PORT' 'http://$host:$server_port';

        proxy_pass         http://GERBERA_IP:GERBERA_PORT/;
    }
}

ngx_http_sub_module

The directive sub_filter_once is from nginx module ngx_http_sub_module.
However, those directives failed for me

$ service nginx restart; systemctl status nginx.service
...
unknown directive "sub_filter_once" in /etc/nginx/sites-enabled/gerbera:15

(I have installed apt packages nginx-common nginx-light on a recent Debian)

ngx_http_subs_filter_module

Looking at the example again, it refers to

# load_module /usr/lib64/nginx/modules/ngx_http_subs_filter_module.so;

I was able to install via apt install libnginx-mod-http-subs-filter.

That refers to ngx_http_substitutions_filter_module.
That modules documentation does not have sub_filter_once directive.
Instead, it has similar (but not the same) directives subs_filter_types and subs_filter.

I manually changed the nginx.conf directives to:

subs_filter_types   text/html application/json;
subs_filter         'http://gerbera.myhost.local:80' 'http://$host:$server_port';

However, this resulted in a HTTP 500 error (tested using curl -v http://gerbera.myhost.local).

different modules!

It appears there was some divergence or overlap of similarly-named nginx modules ngx_http_subs_filter_module and ngx_http_sub_module.

Could a gerbera expert clarify the nginx.conf example in the docs?

gerbera was installed using apt, version 1.1.0.

@KarlStraussberger
Copy link
Member

I have the following modules loaded in my nginx.conf:

load_module /usr/lib64/nginx/modules/ngx_http_headers_more_filter_module.so;
load_module /usr/lib64/nginx/modules/ngx_http_subs_filter_module.so;

and the example was just copied from vhosts.d/

This config was tested for something like gerbera 1.6. Older versions may not work as described. So you'd better try to get something newer.

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