Answer the question
In order to leave comments, you need to log in
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
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;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question