CentOS under Nginx Support HTTPS protocol

Source: Internet
Author: User
Tags openssl rsa openssl x509

1, the first configuration nginx and other plug-ins, this Google, a lot of configuration options.

2. Configure the server's certificate. The procedure is as follows:

[Email protected] ~]# cd/etc/pki/tls/certs [[email protected] certs]# MakeServer.key umask the ; /usr/bin/openssl genrsa-aes1282048>server.keygenerating RSA private key,2048BitLongModulus ..... ..... ..... ..... ... .. ................-.....-........++++++.............++++++e is61251(0x10001) Enter Pass phrase:# set passphraseverifying-Enter Pass phrase:# confirm# remove passphrase from private key[[email protected] certs]# OpenSSL RSA-inchServer.key-Out Server.key Enter pass phrase forserver.key:# input passphrasewriting RSA key[[email protected] certs]#[[email protected] certs]# MakeSERVER.CSR umask the ; /usr/bin/openssl Req-utf8-new-key Server.key-Out Server.csryou is about to being asked to enter information that'll be Incorporatedinto your certificate request. What's about-to-enter is called a distinguished Name or a DN. There is quite a few fields but can leave some blankfor some fields there would be a default value,if you enter'.'The field would be a left blank.-----Country Name (2Letter Code) [Xx]:cn #countryState or province name (full name) [e]:beijing #stateLocality name (eg, city) [Default city]:beijing #c Ityorganization name (eg, company) [Default company Ltd]:test #companyOrganizational Unit Name (eg, section) []:test Hah A #departmentCommon Name (eg, your server's hostname) []:www.test.com #server's Fqdnemail Address []:[email protected] # email Addressplease Enter the following'Extra'Attributesto be sent with your certificate Requesta challenge password []:# Enteran optional Company name []:# enter[ [Email protected] certs]#[[email protected] certs]# OpenSSL x509-inchServer.csr-out Server.crt-req-signkey Server.key-days3650Signature Oksubject=/c=cn/st=beijing/l=beijing/o=test/ou=test haha/cn=www.test.com,/emailaddress=[email protected]
Getting Private key[[email protected] certs]#chmod -Server.*

3. Configure Nginx conf file

The Nginx of my test machine is installed in the/data/server/nginx directory, the configuration file is under the/data/server/nginx/conf/directory.

VI nginx.conf

The SSL section is configured as follows

    server {        #listen       ;        Listen         default_server;        Listen       443  SSL;        server_name  localhost;        Ssl_certificate      /etc/pki/tls/certs/server.crt;        Ssl_certificate_key  /etc/pki/tls/certs/server.key;        #charset Koi8-R;

Reload the configuration file.

4. Open the 443 port of CentOS with Iptables

VI /etc/sysconfig/iptables

Add a row

443 -j ACCEPT

Restart the Iptables service.

CentOS under Nginx Support HTTPS protocol

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.