K
K
Konstantin B.2017-02-14 11:47:58
Nginx
Konstantin B., 2017-02-14 11:47:58

How to enable sub_filter in nginx?

I don't know much about administration, but one thing needs to be done, namely, have a site running on one service. They do not have https and all sites are running on the same IP with not very good karma, I decided to leave them for a third-party IP using a proxy. I took the VPS and set it up, also connected the site to HTTPS, but the trouble is, they don’t have https, which means I can’t tell the server that we have https, and it gives all the content with http links, which of course make our site unsafe. I read that there is a sub_filter utility in Nginx that works like find and replace, but it doesn’t come standard, but I still don’t understand how to install it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Mikhalev, 2017-02-15
@Kostik_1993

It most likely works, but only until the first match.
Carefully read the page nginx.org/ru/docs/http/ngx_http_sub_module.html
Namely, sub_filter_once , it is enabled by default (and you have this line in the config), and will replace only the first match.
If you need to make all the replacements on the page, then you should change the config:

location / {
        sub_filter 'http://' 'https://';
        sub_filter_once off;
    }

A
Andrew, 2017-02-14
@R0dger

Religion does not allow to fix DNS?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question