Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#846 closed defect (invalid)

HTTP2 apply to all server block

Reported by: Jan Trejbal Owned by:
Priority: minor Milestone: 1.9.8
Component: nginx-module Version: 1.9.x
Keywords: http2 server Cc:
uname -a: Linux bbb6fdf82301 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.9.7
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

Description

If I have this configuration:

server {
        server_name www.domain.tld;
        listen 443 ssl; #http1.1
        listen 80;
        ssl_certificate         /etc/nginx/certs/...;
        ssl_certificate_key     /etc/nginx/certs/...;
        include ssl.conf;
        ssl_trusted_certificate /etc/nginx/certs/...;

        rewrite ^ https://domain.tld$request_uri? permanent;
}
server {
        server_name domain.tld;
        listen 443 ssl http2;
        listen 80;
        ssl_certificate         /etc/nginx/certs/...;
        ssl_certificate_key     /etc/nginx/certs/...;
        include ssl.conf;
        ssl_trusted_certificate /etc/nginx/certs/...;

        location {
                ...
        }
}

https://www.domain.tld use HTTP2

curl --http2 https://www.domain.tld/ -I
HTTP/2.0 301 Moved Permanently

Than if i remove directive http2 from server domain.tld all is well.

curl --http2 https://www.domain.tld/ -I
HTTP/1.1 301 Moved Permanently

Change History (2)

comment:1 by Maxim Dounin, 5 years ago

Resolution: invalid
Status: newclosed

The http2 parameter is a parameter of the listen directive, and it applies to the listen socket in question, much like ssl. If you enable http2 on a listening socket, it's enabled for all servers where the socket is used.

comment:2 by shereenz89, 3 years ago

}
server {

server_name domain.tld;
listen 443 ssl http2;
listen 80;
ssl_certificate /etc/nginx/certs/...;
ssl_certificate_key /etc/nginx/certs/...;
include ssl.conf;
ssl_trusted_certificate /etc/nginx/certs/...;

location {

...server {

server_name www.domain.tld;
listen 443 ssl; #http1.1
listen 80;
ssl_certificate /etc/nginx/certs/...;
ssl_certificate_key /etc/nginx/certs/...;
include ssl.conf;
ssl_trusted_certificate /etc/nginx/certs/...;

rewaste not rewrite https://domain.tld$request_uri? permanent;

Note: See TracTickets for help on using tickets.