Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configure nginx to use http2 while hiding version information

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Configure nginx to use http2

1. Configure openssl

Openssl version must be greater than 1.0.2 version

Yum install-y gcc zlib-devel pcre-devel

Wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz

Tar zxvf openssl-1.1.0g.tar.gz

Cd openssl-1.1.0g

. / config-- prefix=/usr/local/openssl shared zlib

Make & & make install

Mv / usr/bin/openssl / usr/bin/openssl.old

Ln-s / usr/local/openssl/bin/openssl / usr/bin/openssl

Ln-s / usr/local/openssl/include/openssl / usr/include/openssl

Ln-s / usr/local/openssl/lib/libssl.so.1.1 / lib/x86_64-linux-gnu

Echo / usr/local/openssl/lib > > / etc/ld.so.conf

Ln-s / usr/local/openssl/lib/libssl.so / usr/local/lib64/libssl.so

Ln-s / usr/local/openssl/lib/libcrypto.so / usr/local/lib64/libcrypto.so

Ldconfig-v makes the configuration effective

Openssl version View version

Tar xf nginx-1.14.2.tar.gz

Cd nginx-1.14.2

Vim src/core/nginx.h removes the version information, and these two lines are modified to

# define NGINX_VERSION ""

# define NGINX_VER "Tengine/" NGINX_VERSION

. / configure-- prefix=/usr/local/nginx-- with-http_v2_module-- with-http_ssl_module

Make & & make install

Cd / usr/local/nginx

2. Configure nginx.conf

Vim conf/nginx.conf

Http {

Include mime.types

Default_type application/octet-stream

Sendfile on

Tcp_nopush on

Keepalive_timeout 65

Gzip_min_length 1k

Gzip_comp_level 6

Gzip on

Gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/png application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml

Server {

Listen 80

Server_name abc.com

Rewrite "^ / (. *) $" https://abc.com$1; # forces access to https

}

Server {

Listen 443 ssl http2; # http2 must use https

Server_name abc.com

Ssl_certificate / root/ssl/fullchain.crt

Ssl_certificate_key / root/ssl/private.pem

Ssl_protocols TLSv1.1 TLSv1.2

Ssl_ciphers ECDHEMUR AES128MUG CMUM SHA256 Flex HIGHVOV A NULLLOR MD5 RC4 RC4

Ssl_prefer_server_ciphers on

Ssl_session_cache shared:SSL:1m

Ssl_session_timeout 5m

Location / {

Root html

Index index.html index.htm

}

}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report