Cấu hình tự động chuyển từ HTTP sang HTTPS

Mr LNA

Administrator
1 Tháng mười một 2010
49,064
12
38
[FONT=&quot]Sau khi hoàn tất quá trình đăng ký, cũng như cài đặt SSL (CRT) lên server hoặc các phần mềm quản trị web server. Việc chứng thực SSL của website hầu như đã hoàn chỉnh, bạn đã có thể kiểm tra việc chứng thực hoặc truy cập website bằng giao thức https.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Để hoàn tất bước cuối cùng, cấu hình để website tự động truy cập thông qua giao thức https, bạn vui lòng tham khảo thêm hướng dẫn cấu hình từ bài viết sau:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]I. Cấu hình chuyển hướng sang https trên Linux (bao gồm cấu hình trên server linux và một số mã nguồn php thông dụng).[/FONT]
[FONT=&quot]1.Cấu hình trên Apache[/FONT]
[FONT=&quot]Bạn có thể dùng file .htaccess vốn luôn được hỗ trợ bởi các máy chủ chạy Apache. Mở file .htaccess và tìm đoạn sau:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]RewriteEngine On[/FONT]
[FONT=&quot]RewriteCond %{<b class=”searchkeyword”>HTTPS</b>} !=on[/FONT]
[FONT=&quot]RewriteRule ^.*$ <b class=”searchkeyword”>https</b>://%{SERVER_NAME}%{REQUEST_URI} [R,L][/FONT]
[FONT=&quot]Hoặc[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]RewriteEngine On[/FONT]
[FONT=&quot]RewriteCond %{<b class=”searchkeyword”>HTTPS</b>} off[/FONT]
[FONT=&quot]RewriteRule (.*) <b class=”searchkeyword”>https</b>://%{HTTP_HOST}%{REQUEST_URI}[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]2.Cấu hình trên Nginx[/FONT]
[FONT=&quot]Chúng ta mở file cấu hình nginx.conf (hoặc /etc/nginx/sites-enabled/domain.conf) và tìm đoạn cấu hình cho website trên port 80, sau đó điều chỉnh như sau:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]server {[/FONT]
[FONT=&quot]listen 80;[/FONT]
[FONT=&quot]server_name yourdomain.com;[/FONT]
[FONT=&quot]return 301 <b class=”searchkeyword”>https</b>://$server_name$request_uri;[/FONT]
[FONT=&quot]}[/FONT]
[FONT=&quot]Cuối cùng khởi động lại nginx: service nginx restart[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]3.Cấu hình trên Tomcat/JBoss[/FONT]
[FONT=&quot]Đầu tiên bạn mở file cấu hình server.xml của Tomcat (thường nằm trong thư mục tomcat/conf) và tìm các đoạn cấu hình cho các port 80 và 443.[/FONT]
[FONT=&quot]Trong phần cấu hình port 80 chỉnh lại như bên dưới:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]<Connector port=”443″ maxHttpHeaderSize=”8192″ maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″ enableLookups=”false” disableUploadTimeout=”true” acceptCount=”100″ scheme=”<b class=”searchkeyword”>https</b>” secure=”true” SSLEnabled=”true” clientAuth=”false” sslProtocol=”TLS” keyAlias=”tomcat” keystoreFile=”/usr/local/ssl/keystore/server.jks” keystorePass=”your_keystore_password” />[/FONT]
[FONT=&quot]<Connector port=”80″ enableLookups=”false” redirectPort=”443″ />[/FONT]
[FONT=&quot]Tiếp theo đến file cấu hình web.xml của website và thêm vào đoạn sau đây ở cuối file, nhưng trước thẻ </web-app>[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]<!– SSL settings. Only allow <b class=”searchkeyword”>HTTPS</b> access –>[/FONT]
[FONT=&quot]<security-constraint>[/FONT]
[FONT=&quot]<web-resource-collection>[/FONT]
[FONT=&quot]<web-resource-name>Entire Application</web-resource-name>[/FONT]
[FONT=&quot]<url-pattern>/*</url-pattern>[/FONT]
[FONT=&quot]</web-resource-collection>[/FONT]
[FONT=&quot]<user-data-constraint>[/FONT]
[FONT=&quot]<transport-guarantee>CONFIDENTIAL</transport-guarantee>[/FONT]
[FONT=&quot]</user-data-constraint>[/FONT]
[FONT=&quot]</security-constraint>[/FONT]
[FONT=&quot]Sau đó bạn cần khởi động lại Tomcat.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]II. Cấu hình chuyển hướng sang https trên Windows (bao gồm cấu hình trên IIS các phiên bản).[/FONT]
[FONT=&quot]1.Cấu hình chung[/FONT]
[FONT=&quot]Đầu tiên chúng ta khởi động Internet Information Services (IIS) Manager, tìm đến website cần cấu hình. Trong khung HOME của website bạn >>> double click SSL Settings >>> bật Client Certificates = Accept >>> Apply.[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]Lưu ý: không chọn cấu hình Require SSL[/FONT]
[FONT=&quot]Tiếp theo là cài đặt module URL Rewrite 2.0, bạn có thể download trực tiếp module này từ các link mà Microsoft cung cấp như sau:[/FONT]
[FONT=&quot]+ Phiên bản 64 bit cho IIS8 >>>link tải: go.microsoft.com/?linkid=9722532[/FONT]
[FONT=&quot]+ Phiên bản 32 bit cho IIS8 >>>link tải: go.microsoft.com/?linkid=9722533[/FONT]
[FONT=&quot]+ Phiên bản 64 bit cho IIS7 >>>link tải: go.microsoft.com/fwlink/?LinkID=615137[/FONT]
[FONT=&quot]+ Phiên bản 32 bit cho IIS7 >>>link tải: go.microsoft.com/fwlink/?LinkID=615138[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]2.Cấu hình trên IIS 8.x[/FONT]
[FONT=&quot]Sau khi cài đặt thành công cũng trong khung HOME của website cần cấu hình bạn double click URL Rewrite >>> Add Rule >>> Inbound Rule >>> Blank Rule >>> cấu hình như sau:[/FONT]
[FONT=&quot]NAME : http to https[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]MATCH URL :[/FONT]
[FONT=&quot]+ Requested URL: Matches the Pattern[/FONT]
[FONT=&quot]+ Using: Regular Expression[/FONT]
[FONT=&quot]+ Pattern: (.*)[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]CONDITIONS >>> Add[/FONT]
[FONT=&quot]+ Condition Input: {HTTPS}[/FONT]
[FONT=&quot]+ Check if input string: Matches the Pattern[/FONT]
[FONT=&quot]+ Pattern: ^OFF$[/FONT]
[FONT=&quot]+ Nhấn OK[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot] [/FONT]
[FONT=&quot]ACTION[/FONT]
[FONT=&quot]+ Action type: Redirect[/FONT]
[FONT=&quot]+ Redirect URL: https://{HTTP_HOST}/{R:1}[/FONT]
[FONT=&quot]+ Redirect type: See Other (303)[/FONT]
[FONT=&quot]+ Nhấn Apply[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]3.Cấu hình trên IIS 7.x[/FONT]
[FONT=&quot]Sau khi cài đặt thành công module trên, bạn bổ sung đoạn cấu hình sau vào file web.config trong thư mục gốc của website – giữa các thẻ <rewrite><rules> và </rules></rewrite> như sau:[/FONT]
[FONT=&quot]<rule name=”Redirect to <b class=”searchkeyword”>HTTPS</b>” stopProcessing=”true”>[/FONT]
[FONT=&quot]<match url=”(.*)” />[/FONT]
[FONT=&quot]<conditions><add input=”{<b class=”searchkeyword”>HTTPS</b>}” pattern=”^OFF$” />[/FONT]
[FONT=&quot]</conditions>[/FONT]
[FONT=&quot]<action type=”Redirect” url=”<b class=”searchkeyword”>https</b>://{HTTP_HOST}/{R:1}” redirectType=”SeeOther” />[/FONT]
[FONT=&quot]</rule>

Nguồn: wiki.matbao.net[/FONT]
 

New Jobs

Thống kê diễn đàn

Chủ đề
61,151
Bài viết
63,371
Thành viên
86,048
Thành viên mới nhất
BLOCK ĐIỀU HÒA DANFOSS

VỀ CHÚNG TÔI

  • Sinhvienthamdinh.Com là diễn đàn đầu tiên và lớn nhất dành riêng cho cộng đồng nhân lực ngành thẩm định giá. Cổng thông tin được tạo ra nhằm tạo kênh kết nối tri thức cho tất cả các bạn đã và đang quan tâm đến ngành thẩm định giá. Các thông tin được tổng hợp với đầy đủ các mảng thuộc lĩnh vực thẩm định giá như: Thẩm định giá Bất động sản, thẩm định giá động sản, thẩm định giá máy móc thiết bị, thẩm định giá doanh nghiệp, thẩm định giá dự án đầu tư, thẩm định giá thương hiệu...
  • Với phương châm "Connet For Sharing" chúng tôi chia sẻ hoàn toàn miễn phí và không giới hạn những kiến thức từ cộng đồng diễn đàn.

DANH MỤC CHÍNH

CÁ NHÂN