replace http header link by sub_filter link

This commit is contained in:
Valentin CZERYBA 2023-03-19 11:51:50 +01:00
parent 178fe9fcf4
commit e821c4d26a

View File

@ -7,14 +7,16 @@ server {
if ($host = clarissariviere.com) { if ($host = clarissariviere.com) {
return 301 https://"www.clarissariviere.com"$request_uri; return 301 https://"www.clarissariviere.com"$request_uri;
} # managed by Certbot } # managed by Certbot
set $link 'canonical';
if ($host = www.clarissariviere.fr) {
set $link "alternate\" hreflang=\"fr";
}
access_log /var/log/nginx/clarissa_access.log main; access_log /var/log/nginx/clarissa_access.log main;
error_log /var/log/nginx/clarissa_error.log; error_log /var/log/nginx/clarissa_error.log;
#gzip_static off; #gzip_static off;
server_name clarissariviere.com clarissariviere.fr www.clarissariviere.fr www.clarissariviere.com; server_name clarissariviere.com clarissariviere.fr www.clarissariviere.fr www.clarissariviere.com;
add_header 'Content-Security-Policy' 'upgrade-insecure-requests'; add_header 'Content-Security-Policy' 'upgrade-insecure-requests';
add_header Link "<https://www.clarissariviere.com;> rel=\"canonical\", <https://www.clarissariviere.fr;> rel=\"alternate\" hreflang=\"fr\""; #add_header Link "<https://www.clarissariviere.com$request_uri;> rel=\"canonical\", <https://www.clarissariviere.fr$request_uri;> rel=\"alternate\" hreflang=\"fr\"";
proxy_cache STATIC; proxy_cache STATIC;
location / { location / {
# First attempt to serve request as file, then # First attempt to serve request as file, then
@ -36,9 +38,9 @@ server {
#proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme; #proxy_set_header X-Forwarded-Proto $scheme;
sub_filter 'canonical' "$link";
sub_filter 'gouters.canalblog.com' "$host"; sub_filter 'gouters.canalblog.com' "$host";
sub_filter '<meta name="generator" content="CanalBlog - https://www.canalblog.com" />' ''; sub_filter '<meta name="generator" content="CanalBlog - https://www.canalblog.com" />' '';
#sub_filter '</head>' '<script async src="https://www.googletagmanager.com/gtag/js?id=G-MV336S1G9W"></script><script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag("js", new Date()); gtag("config", "G-MV336S1G9W");</script></head>';
sub_filter_types text/html text/xml text/plain text/css; sub_filter_types text/html text/xml text/plain text/css;
sub_filter_once off; sub_filter_once off;