Welcome! Log In Create A New Profile


Gzip not work with public IP and port-mapping

Posted by winterlover 
Gzip not work with public IP and port-mapping
June 13, 2023 03:23AM
We are runing nginx on a host which IP is network IP), and there is a public IP such as real) and port 8090. We do the ip-port mapping to on the firewall.

I already add something about gzip into the custom conf file as below:

server {
listen 8090 ssl;
server_name localhost;
access_log /tmp/logs/access.log;
error_log /tmp/logs/error.log;

ssl_certificate /tmp/ssl/server-cert.pem;
ssl_certificate_key /tmp/ssl/private.pem;
ssl_session_cache shared:SSL:1m;

location /dist {
alias /tmp/web/dist;
gzip on;
gzip_static on;
gzip_comp_level 3;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;


There are some js and js.gz file in the directory '/tmp/web/dist', for example abc.js(9MB) and abc.js.gz(2MB).

If I access the js file using the url such as on Chrome, I get the compress data size(2MB) and the response header content-encoding is gzip. It works well via private IP.

But if I access the js file using the url which is on Chrome, I just get the original data size(9MB), and get the "Accept-Ranges: bytes" in response header. It seems that gzip not works via the public IP.

I also access the js file using curl and specify headers 'Accept-Encoding:gzip', and it returns the same result.

I'm not sure if there's something wrong with my configuration or if the data requests have been altered by port mapping through the firewall.

Can anyone give some suggesions to me? Thanks in advance.
open | download - curl_077.png (153 KB)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 111
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 466 on July 09, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready