Nginx support for HTTPS access configuration--Full configuration file

Source: Internet
Author: User

About the introduction of HTTPS online a lot, it is not verbose.

Configuring HTTPS-enabled access requires an SSL module installed in Nginx. The second is to prepare the SSL certificate, the Nginx version of the certificate contains CRT files and key files, this SSL certificate is generally requested from the certification service provider. Assuming that the Nginx service is ready, you now need to increase the support for HTTPS access, just modify the Nginx virtual host configuration file.

Take a look at the complete configuration file, and there are several important places to write comments.

# your.domain.name.conf# This piece is listening to 80 port access request, that is, HTTP access # can decide to listen to the 80 port, if necessary, you can delete the server {Listen 80;    Listen [::]:80;    server_name your.domain.name;        Root/your/web/root/path; # REDIRECT HTTP access to HTTPS rewrite ^ (. *) $ https://$host $ permanent;}    # # #server {# Listen for access requests from port 443, which is HTTPS access listen 443;    Listen [::]:443;    server_name your.domain.name;    Root/your/web/root/path;    # # if (!-e $request _filename) {rewrite ^ (. *) $/index.php$1 last;    } Access_log/your/web/log/path/your_domain_name.access.log main;    Error_log/your/web/log/path/your_domain_name.error.log info;    # Enable SSL support, then load the CRT and key files SSL on;    SSL_CERTIFICATE/YOUR/CERT/FILE/PATH/YOUR_DOMAIN_NAME/1_YOUR.DOMAIN.NAME_BUNDLE.CRT;    Ssl_certificate_key/your/cert/file/path/your_domain_name/2_your.domain.name.key;    # # # include/etc/nginx/default.d/*.conf; Location/{index index.php index.html;   } location ~. *\.php (\/.*) *$ {fastcgi_pass 127.0.0.1:9000;        Fastcgi_index index.php;        Fastcgi_param script_filename $document _root$fastcgi_script_name;    Include Fastcgi_params;    } error_page 404/404.html;    Location =/40x.html {} error_page 502 503 504/50x.html; Location =/50x.html {}}

Remember to restart the Nginx service after the modification is complete.

The above is Nginx virtual host configuration file, the specific storage location will be somewhat different, I am the CentOS server, nginx configuration files in the /etc/nginx/conf.d/ directory (some hosts provide a deployed Web environment, the path may be different).

On the inside of the configuration content, do not have to take pictures (you can see, I use the server side of the PHP language), as long as the attention of the annotated place.

Nginx support for HTTPS access configuration--Full configuration file

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.