Welcome! Log In Create A New Profile

Advanced

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
Hi
We are runing nginx on a host which IP is 10.25.1.26(private network IP), and there is a public IP such as 1.2.3.4(not real) and port 8090. We do the ip-port mapping 1.2.3.4:8090 to 10.25.1.26:8090 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;
}

#others
}

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 https://10.25.1.26:8090/dist/abc.js 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 https://1.2.3.4:8090/dist/abc.js 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.
Attachments:
open | download - curl_077.png (153 KB)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 133
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready