tengine icon indicating copy to clipboard operation
tengine copied to clipboard

Pls. refer to doc [Ngx_http_trim_filter](https://tengine.taobao.org/document/http_trim_filter.html) specifically.

Open pashunchik opened this issue 1 year ago • 7 comments

it is not work after upgrade Tengine. are have old version 3.0

http { trim on; #trim_js on; trim_css on;

nginx -V Tengine version: Tengine/3.1.0 nginx version: nginx/1.24.0 built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) built with OpenSSL 1.1.1q 5 Jul 2022 TLS SNI support enabled configure arguments: --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/error.log --with-threads --http-log-path=/var/log/nginx/ --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access.log --user=www-data --group=www-data --with-cc-opt=-Wno-error --with-http_realip_module --with-stream_realip_module --with-http_geoip_module --with-stream_geoip_module --add-module=modules/ngx_http_reqstat_module --add-module=modules/ngx_http_trim_filter_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --add-module=src/http/modules/nginx-module-vts --add-module=src/http/modules/ngx_http_geoip2_module --with-http_perl_module --with-openssl=../openssl-1.1.1q/ --with-openssl-opt=enable-tls1_3 --add-module=src/http/modules/ngx_http_lower_upper_case

          Pls. refer to doc  [Ngx_http_trim_filter](https://tengine.taobao.org/document/http_trim_filter.html) specifically.

E.g., image

Tengine conf: image

index.html of upstream with comments: image

The comments was removed from the response of upstream by the tengine: image

Originally posted by @lianglli in https://github.com/alibaba/tengine/issues/1896#issuecomment-1829999721

pashunchik avatar Dec 01 '23 07:12 pashunchik

This function is worked for both tengine 3.0.0 and 3.1.0.

Tengine Conf: image

Upstream Index.html Add comments to the html and css: image image

The above comments has been removed from the response by tengine: $ curl -i https://tengine.daily.taobao.net HTTP/2 200 date: Mon, 04 Dec 2023 03:41:51 GMT content-type: text/html vary: Accept-Encoding server: Tengine Ingress/3.0.1 vary: Accept-Encoding via: tengine-site.011159138070.nt12[web,200]

lianglli avatar Dec 04 '23 03:12 lianglli

What is the MIME type of your response specifically?

Pls. give the URL and response html specifically.

lianglli avatar Dec 04 '23 03:12 lianglli

if I got url from curl - its good trim is work

< HTTP/2 200 < server: Tengine < date: Tue, 05 Dec 2023 08:29:46 GMT < content-type: text/html;charset=UTF-8 < vary: Accept-Encoding < etag: afc30f5a3db5cfeeffb8a93f853e1cce < vary: Accept-Encoding < expires: Tue, 05 Dec 2023 08:29:46 GMT < cache-control: max-age=0 < strict-transport-security: max-age=63072000; includeSubdomains; preload < x-content-type-options: nosniff < x-xss-protection: 1; mode=block < last-modified: Tue, 05 Dec 2023 08:29:46 GMT

when I try from browser - no good trim not work

:status: 200 Cache-Control: max-age=0 Content-Encoding: gzip Content-Length: 41188 Content-Type: text/html;charset=UTF-8 Date: Tue, 05 Dec 2023 08:30:30 GMT ETag: bc013e38b84f461976d0e45098b550fe Expires: Tue, 05 Dec 2023 08:30:30 GMT Last-Modified: Tue, 05 Dec 2023 08:30:30 GMT Server: Tengine Strict-Transport-Security: max-age=63072000; includeSubdomains; preload Vary: Accept-Encoding X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block

pashunchik avatar Dec 05 '23 08:12 pashunchik

In your browser, you should clear cache firstly.

Or, disable cache and access again: image

lianglli avatar Dec 08 '23 02:12 lianglli

Moreover, tcpdump both on the browser and Tengine

Then, you will be able to check the response (without comments) of Tengine specifically.

lianglli avatar Dec 08 '23 03:12 lianglli

In your browser, you should clear cache firstly.

Or, disable cache and access again

i clear cache - Be sure

pashunchik avatar Dec 13 '23 14:12 pashunchik

Moreover, tcpdump both on the browser and Tengine

Then, you will be able to check the response (without comments) of Tengine specifically.

its then not working

curl 'https://XXX/'
-H 'authority: XXX'
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7'
-H 'accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7'
-H 'cache-control: no-cache'
-H 'cookie: rrpvid=284325822774850; rcuid=6316068ff07a9bab2639ed7c; _ym_uid=1662387856981919529; fromcity_id=1; city_id=1; offid3=18; offid_phone=18; tabCookie0=0; tmr_lvid=3538c831ca473f988964da4b50b60c6c; tmr_lvidTS=1684933059472; locationModalConfirm=Moscow; rrlevt=1689928836604; friend_phone=%23search-results; _ym_d=1700489389; _pk_id.1.6b29=bc328ef72cd992e6.1700489433.; _pk_id.1.5fa1=2ef9cc40f27b580c.1700489433.; session_init=true; _gid=GA1.2.231223324.1702476401; counterVisitedPages=1; _ga_TCXF2WBQL7=GS1.1.1702476400.31.0.1702476400.60.0.0; startAdvert=start_jivo; JivoSiteLoaded=1; _ym_isad=2; _pk_ses.1.5fa1=1; user1001nw=bc328ef72cd992e6; tmr_detect=0%7C1702476403562; resultComebackerShowClose=true; _ga=GA1.2.1712846012.1662387856; spsearch=1; 60sec_ap=36; comebacker_price_calc_Start=60000; comebacker_price_calc_Stop=true; country_id=1; comebacker_price_calc=true; rrwps=true; rrwps=true; tzm_agreement=iagree; 120sec_ap=4; _pk_ref.1.6b29=%5B%22%22%2C%22%22%2C1702476726%2C%22https%3A%2F%2Fhotels.XXX%2F%22%5D'
-H 'pragma: no-cache'
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "macOS"'
-H 'sec-fetch-dest: document'
-H 'sec-fetch-mode: navigate'
-H 'sec-fetch-site: none'
-H 'sec-fetch-user: ?1'
-H 'upgrade-insecure-requests: 1'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
--compressed

  • Trying XXX:443...
  • Connected to XXX (XXX) port 443 (#0)
  • ALPN: offers h2,http/1.1
  • (304) (OUT), TLS handshake, Client hello (1):
  • CAfile: /etc/ssl/cert.pem
  • CApath: none
  • (304) (IN), TLS handshake, Server hello (2):
  • (304) (IN), TLS handshake, Unknown (8):
  • (304) (IN), TLS handshake, Certificate (11):
  • (304) (IN), TLS handshake, CERT verify (15):
  • (304) (IN), TLS handshake, Finished (20):
  • (304) (OUT), TLS handshake, Finished (20):
  • SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
  • ALPN: server accepted h2
  • Server certificate:
  • subject: CN=*.XXX
  • start date: Apr 10 17:34:59 2023 GMT
  • expire date: May 11 17:34:58 2024 GMT
  • subjectAltName: host "XXX" matched cert's "*.XXX
  • issuer: C=BE; O=GlobalSign nv-sa; CN=AlphaSSL CA - SHA256 - G4
  • SSL certificate verify ok.
  • using HTTP/2
  • h2 [:method: GET]
  • h2 [:scheme: https]
  • h2 [:authority: XXX]
  • h2 [:path: /]
  • h2 [accept-encoding: deflate, gzip]
  • h2 [authority: XXX]
  • h2 [accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7]
  • h2 [accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7]
  • h2 [cache-control: no-cache]
  • h2 [cookie: rrpvid=284325822774850; rcuid=6316068ff07a9bab2639ed7c; _ym_uid=1662387856981919529; fromcity_id=1; city_id=1; offid3=18; offid_phone=18; tabCookie0=0; tmr_lvid=3538c831ca473f988964da4b50b60c6c; tmr_lvidTS=1684933059472; locationModalConfirm=Moscow; rrlevt=1689928836604; friend_phone=%23search-results; _ym_d=1700489389; _pk_id.1.6b29=bc328ef72cd992e6.1700489433.; _pk_id.1.5fa1=2ef9cc40f27b580c.1700489433.; session_init=true; _gid=GA1.2.231223324.1702476401; counterVisitedPages=1; _ga_TCXF2WBQL7=GS1.1.1702476400.31.0.1702476400.60.0.0; startAdvert=start_jivo; JivoSiteLoaded=1; _ym_isad=2; _pk_ses.1.5fa1=1; user1001nw=bc328ef72cd992e6; tmr_detect=0%7C1702476403562; resultComebackerShowClose=true; _ga=GA1.2.1712846012.1662387856; spsearch=1; 60sec_ap=36; comebacker_price_calc_Start=60000; comebacker_price_calc_Stop=true; country_id=1; comebacker_price_calc=true; rrwps=true; rrwps=true; tzm_agreement=iagree; 120sec_ap=4; _pk_ref.1.6b29=%5B%22%22%2C%22%22%2C1702476726%2C%22https%3A%2F%2Fhotels.XXX%2F%22%5D]
  • h2 [pragma: no-cache]
  • h2 [sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"]
  • h2 [sec-ch-ua-mobile: ?0]
  • h2 [sec-ch-ua-platform: "macOS"]
  • h2 [sec-fetch-dest: document]
  • h2 [sec-fetch-mode: navigate]
  • h2 [sec-fetch-site: none]
  • h2 [sec-fetch-user: ?1]
  • h2 [upgrade-insecure-requests: 1]
  • h2 [user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36]
  • Using Stream ID: 1 (easy handle 0x7f7aee80ce00)

GET / HTTP/2 Host: XXX Accept-Encoding: deflate, gzip authority: XXX accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7 accept-language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7 cache-control: no-cache cookie: rrpvid=284325822774850; rcuid=6316068ff07a9bab2639ed7c; _ym_uid=1662387856981919529; fromcity_id=1; city_id=1; offid3=18; offid_phone=18; tabCookie0=0; tmr_lvid=3538c831ca473f988964da4b50b60c6c; tmr_lvidTS=1684933059472; locationModalConfirm=Moscow; rrlevt=1689928836604; friend_phone=%23search-results; _ym_d=1700489389; _pk_id.1.6b29=bc328ef72cd992e6.1700489433.; _pk_id.1.5fa1=2ef9cc40f27b580c.1700489433.; session_init=true; _gid=GA1.2.231223324.1702476401; counterVisitedPages=1; _ga_TCXF2WBQL7=GS1.1.1702476400.31.0.1702476400.60.0.0; startAdvert=start_jivo; JivoSiteLoaded=1; _ym_isad=2; _pk_ses.1.5fa1=1; user1001nw=bc328ef72cd992e6; tmr_detect=0%7C1702476403562; resultComebackerShowClose=true; _ga=GA1.2.1712846012.1662387856; spsearch=1; 60sec_ap=36; comebacker_price_calc_Start=60000; comebacker_price_calc_Stop=true; country_id=1; comebacker_price_calc=true; rrwps=true; rrwps=true; tzm_agreement=iagree; 120sec_ap=4; _pk_ref.1.6b29=%5B%22%22%2C%22%22%2C1702476726%2C%22https%3A%2F%2FXXX%2F%22%5D pragma: no-cache sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "macOS" sec-fetch-dest: document sec-fetch-mode: navigate sec-fetch-site: none sec-fetch-user: ?1 upgrade-insecure-requests: 1 user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

< HTTP/2 200 < server: Tengine < date: Wed, 13 Dec 2023 14:16:02 GMT < content-type: text/html;charset=UTF-8 < content-length: 41744 < etag: aa856f43cbb6f2281c0e4defb922716e < vary: Accept-Encoding < content-encoding: gzip < expires: Wed, 13 Dec 2023 14:16:02 GMT < cache-control: max-age=0 < strict-transport-security: max-age=63072000; includeSubdomains; preload < x-content-type-options: nosniff < x-xss-protection: 1; mode=block < last-modified: Wed, 13 Dec 2023 14:16:02 GMT <

pashunchik avatar Dec 13 '23 14:12 pashunchik