<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NGINX &#8211; Nhật Phúc</title>
	<atom:link href="https://nhatphuc.com/bai-viet/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>https://nhatphuc.com</link>
	<description></description>
	<lastBuildDate>Mon, 25 Dec 2023 04:06:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://nhatphuc.com/wp-content/uploads/2019/08/favicon-75x75.png</url>
	<title>NGINX &#8211; Nhật Phúc</title>
	<link>https://nhatphuc.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Cách bật HTTP/2.0 trong Nginx</title>
		<link>https://nhatphuc.com/cach-bat-http-2-0-trong-nginx/</link>
					<comments>https://nhatphuc.com/cach-bat-http-2-0-trong-nginx/#respond</comments>
		
		<dc:creator><![CDATA[Linh Nguyễn]]></dc:creator>
		<pubDate>Wed, 24 Jun 2020 14:20:23 +0000</pubDate>
				<category><![CDATA[Học công nghệ]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NGINX]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[System]]></category>
		<guid isPermaLink="false">http://nhatphuc.com/?p=1466</guid>

					<description><![CDATA[<p>HTTP/2 hoặc HTTP phiên bản 2.0 là phiên bản thứ hai của giao thức mạng [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nhatphuc.com/cach-bat-http-2-0-trong-nginx/">Cách bật HTTP/2.0 trong Nginx</a> appeared first on <a rel="nofollow" href="https://nhatphuc.com">Nhật Phúc</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="http://nhatphuc.com/http-2/">HTTP/2</a> hoặc HTTP phiên bản 2.0 là phiên bản thứ hai của giao thức mạng HTTP quá quen thuộc cho đến ngày nay. Giao thức này dựa trên SPDY/2 để cải thiện hiệu suất web ở mức độ rất lớn.</p>
<p>HTTP/2.0 được tạo ra nhằm sử dụng hiệu quả hơn các nguồn lực mạng và giảm độ trễ bằng cách nén header và cho phép các lưu lượng đồng thời lưu thông trên cùng một kết nối.</p>
<p>HTTP/1.1 dùng data dạng text, với hiệu năng nhìn chung kém hơn khi áp dụng lên môi trường mạng. HTTP/2 Headers được nén nhỏ Thông tin được gửi đi kèm request miêu tả dữ liệu, cùng nguồn gốc, kiểu, độ dài, và thời gian được cache,… của dữ liệu đó. Khác với HTTP/1.1, tất cả thông tin này được nén trong HTTP/2.</p>
<p>Trong HTTP/1.1, server phải gửi phản hồi theo cùng trật tự nhận request. HTTP/2 thì bất đồng bộ, nên các phản hồi nhỏ hơn hoặc nhanh hơn có thể được xử lý sớm hơn.</p>
<p>Trong bài viết này, bạn sẽ tìm hiểu cách kích hoạt Nginx với hỗ trợ HTTP/2 trong các máy chủ Linux.</p>
<p><strong>Điều kiện:</strong></p>
<ul>
<li>Server cài NGINX phiên bản 1.9.5 trở lên, đã cài module ngx_http_v2_module.</li>
<li>Đảm bảo rằng trang web của bạn sử dụng chứng chỉ SSL/TLS, nếu bạn không có chứng chỉ, bạn có thể tạo miễn phí từ Lets Encrypt.</li>
</ul>
<h3><strong>Cách bật HTTP/2.0 trong NGINX</strong></h3>
<p>Nếu bạn đã cài đặt NGINX, hãy tìm hiểu xem nó đã bật module ngx_http_v2_module chưa bằng cách chạy lệnh bên dưới:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># strings /usr/sbin/nginx | grep _module | grep -v configure| sort | grep ngx_http_v2_module</pre>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1467" src="http://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module.png" alt="Cách bật HTTP/2.0 trong Nginx 3" width="990" height="105" title="Cách bật HTTP/2.0 trong Nginx 3" srcset="https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module.png 990w, https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module-600x64.png 600w, https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module-320x34.png 320w, https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module-960x102.png 960w, https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module-768x81.png 768w, https://nhatphuc.com/wp-content/uploads/2020/06/verify-if-nginx-is-built-with-http2-support-module-750x80.png 750w" sizes="(max-width: 990px) 100vw, 990px" /></p>
<p>Khi bạn có một trang web chạy NGINX đã bật HTTPS, hãy mở tập tin virtual server (hoặc virtual hosts ) của trang web của bạn để chỉnh sửa.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># vi /etc/nginx/conf.d/example.com.conf                    [Trên CentOS/RHEL]
$ sudo nano /etc/nginx/sites-available/example.com.conf    [Trên Ubuntu/Debian]</pre>
<p>Bạn có thể kích hoạt hỗ trợ HTTP/2 bằng cách thêm tham số http2 vào tất cả các lệnh listen như trong ảnh chụp màn hình bên dưới:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">listen 443 ssl http2;</pre>
<p>Dưới đây là config mẫu:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">server {
        server_name example.com www.example.com;
        access_log  /var/log/nginx/example.com_access.log;
        error_log  /var/log/nginx/example.com_error.log;

        listen [::]:443 ssl ipv6only=on http2; # managed by Certbot
        listen 443 ssl http2; # managed by Certbot

        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot    
}</pre>
<p><img decoding="async" class="aligncenter size-full wp-image-1468" src="http://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration.png" alt="Cách bật HTTP/2.0 trong Nginx 4" width="868" height="346" title="Cách bật HTTP/2.0 trong Nginx 4" srcset="https://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration.png 868w, https://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration-600x239.png 600w, https://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration-320x128.png 320w, https://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration-768x306.png 768w, https://nhatphuc.com/wp-content/uploads/2020/06/enable-https-in-nginx-configuration-750x299.png 750w" sizes="(max-width: 868px) 100vw, 868px" /></p>
<p>Lưu lại file và dùng lệnh bên dưới để restart lại NGINX.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># nginx -t
# systemctl restart nginx</pre>
<p>Bây giờ bạn cần vào trình duyệt và mở trang web lên. Để biết được trang web chạy Protocol này, bạn cần bấm phải chuột &gt; chọn Inspect &gt; Chuyển qua tab Network. Xem hiển thị ở cột Protocol.</p>
<div id="attachment_1469" style="width: 1077px" class="wp-caption aligncenter"><img decoding="async" aria-describedby="caption-attachment-1469" class="size-full wp-image-1469" src="http://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1.png" alt="Cách bật HTTP/2.0 trong Nginx 5" width="1067" height="334" title="Cách bật HTTP/2.0 trong Nginx 5" srcset="https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1.png 1067w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1-600x188.png 600w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1-320x100.png 320w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1-960x301.png 960w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1-768x240.png 768w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-1.1-750x235.png 750w" sizes="(max-width: 1067px) 100vw, 1067px" /><p id="caption-attachment-1469" class="wp-caption-text">Đây là protocol HTTP 1.0</p></div>
<div id="attachment_1470" style="width: 1081px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-1470" class="size-full wp-image-1470" src="http://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2.png" alt="Cách bật HTTP/2.0 trong Nginx 6" width="1071" height="337" title="Cách bật HTTP/2.0 trong Nginx 6" srcset="https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2.png 1071w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2-600x189.png 600w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2-320x101.png 320w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2-960x302.png 960w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2-768x242.png 768w, https://nhatphuc.com/wp-content/uploads/2020/06/website-running-on-http-2-750x236.png 750w" sizes="auto, (max-width: 1071px) 100vw, 1071px" /><p id="caption-attachment-1470" class="wp-caption-text">Đây là protocol HTTP/2.0</p></div>
<p>Theo <em>tecmint</em></p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://nhatphuc.com/cach-bat-http-2-0-trong-nginx/">Cách bật HTTP/2.0 trong Nginx</a> appeared first on <a rel="nofollow" href="https://nhatphuc.com">Nhật Phúc</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nhatphuc.com/cach-bat-http-2-0-trong-nginx/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
