Compile Nginx support Https+http2+nginx-http-concat module

Source: Internet
Author: User

Many websites now require HTTPS access, both to improve security and to avoid carrier hijacking. You must add these functions to Nginx.

Note: The compilation of Nginx requires the installation of GCC gcc-c++.

Pcre

Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

I'm using the 8.39 version of Pcre.

OpenSSL source Package:

https://www.openssl.org/source/or https://github.com/openssl/openssl/releases/

Nginx-http-concat Source Package:

Https://github.com/alibaba/nginx-http-concat

Nginx-http-concat Usage Note:

https://www.nginx.com/resources/wiki/modules/concat/

Https://github.com/alibaba/nginx-http-concat

Nginx version:

nginx-1.11.5.tar.gz (website download)


Prepare the source file:

The source code of these software and the decompression after storing in/home/tools/, the steps skipped.


1, modified under Nginx-http-concat Source:

Edit ngx_http_concat_module.c Modify the 33rd line and change the original x-javascript to JavaScript to save the exit. (For specific reasons please google)


2. Compile and install Nginx

Groupadd Web

USERADD-G Web Web

cd/home/tools/nginx-1.11.5

./configure--prefix=/alidata/server/nginx \

--user=web--group=web \

--with-http_stub_status_module--with-http_ssl_module \

--with-http_gunzip_module--with-http_gzip_static_module \

--with-http_realip_module--with-file-aio \

--with-http_secure_link_module--with-http_auth_request_module \

--with-http_random_index_module--with-http_addition_module \

--with-poll_module--with-select_module \

--with-pcre=/home/tools/pcre-8.39 \

--add-module=/home/tools/nginx-http-concat \

--with-http_v2_module \

--with-openssl=/home/tools/openssl-1.1.0c


Make-j 4 && make install


Echo ' Export path=/alidata/server/nginx/sbin: $PATH ' >/etc/profile.d/nginx.sh

source/etc/profile.d/nginx.sh



Then configure the nginx.conf inside:

server {

Listen 80;

server_name 192.168.2.11;

Root/alidata/wwwroot;

Index index.html index.php;


Location/{

Root/alidata/wwwroot;

Index index.html index.php;


# The following can be adapted to the actual business environment, and the demo is listed here.

Concat on;

Concat_max_files 20;

Concat_unique off;

}

# The following can be adapted to the actual business environment, and the demo is listed here.

location/static/css/{

Concat on;

Concat_max_files 20;

Concat_unique off;

}

location/static/js/{

Concat on;

Concat_max_files 30;

Concat_unique off;

}

}


How to use:

Prepare 2 JS files 1.js and 2.js, placed in the/alidata/wwwroot directory.

We can access http://192.168.2.11/1.js and http://192.168.2.11/2.js separately in the browser

You can also use http://192.168.2.11/??1.js,2.js this way to load 2 JS files at the same time, this is the role of Nginx-http-concat.



The configuration of HTTPS is similar to the following:

server {

Listen 443;

SSL on;

SSL_CERTIFICATE/DATA/WEB/NGINX_KEY/1_WWW.DEMO.COM_BUNDLE.CRT;

Ssl_certificate_key/data/web/nginx_key/2_www.demo.com.key;

server_name www.demo.com;

Access_log/home/wwwlogs/demo.access.log;

Error_log/home/wwwlogs/demo.error.log;

root HTML;

Index index.html index.htm index.php;

# # Send request back to Tomcat # #

Location/{

Proxy_pass https://127.0.0.1:8443;

# Proxy Settings

Proxy_redirect off;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

Proxy_next_upstream Error timeout Invalid_header http_500 http_502 http_503 http_504;

Proxy_max_temp_file_size 0;

Proxy_connect_timeout 90;

Proxy_send_timeout 90;

Proxy_read_timeout 90;

Proxy_buffer_size 4k;

Proxy_buffers 4 32k;

Proxy_busy_buffers_size 64k;

Proxy_temp_file_write_size 64k;

}

}


Compile Nginx support Https+http2+nginx-http-concat module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.