: This article describes how to configure https for nginx. if you are interested in the PHP Tutorial, refer to it. Recently, the login system was developed. due to password-related issues, requests must be made in https mode, while nginx on the front end of the online system has an authenticated digital certificate. Therefore, our https requests can be parsed online and returned successfully, however, in the Test environment, directly configure the domain name host and return 404.
Therefore, you must configure https-related content on your own.
First, generate a certificate-related file and check the information on the Internet as follows:
# Generate an RSA key
$ Openssl genrsa-des3-out my. key 1024
# Copy a key file that does not require password input
$ Openssl rsa-in my. key-out my_nopass.key
# Generate a certificate request
$ Openssl req-new-key my. key-out my. csr
# Self-issuing certificate
$ Openssl x509-req-days 365-in my. csr-signkey my. key-out my. crt
The 3rd command is used to generate a certificate request, prompting you to enter the province, city, domain name information, etc. what's important is that email must be your domain name suffix. In this way, there is a csr file, which is the csr file when it is submitted to the ssl provider. Of course, I did not apply for a certificate from the certificate provider here, but issued a certificate in step 1.
In this way, you can get a certificate of your own.
Second, enable https in nginx.
Server {
Server_name you.domain.com;
Listen 443;
Ssl on;
Ssl_certificate/opt/conf/nginx/my. crt;
Ssl_certificate_key/opt/conf/nginx/my_nopass.key;
Location /{
Proxy_pass http: // resin-core-webapp;
Include/opt/conf/nginx/proxy-resin.conf;
Client_max_body_size 50 m;
Xss_get on;
Xss_callback_arg 'callback'; // this line does not exist. jsonp cannot be supported.
// If this row does not exist, the frontend cannot obtain the returned data
Add_header 'access-Control-Allow-origin''' $ http_origin ';
// It is added together with the previous row. it is unknown what will happen
Add_header 'access-Control-Allow-Credentials ''true ';
// It is added together with the previous line. it is unknown what will happen
Add_header 'access-Control-Allow-headers ''*';
}
}
Finally, restart nginx. successful:
/Opt/apps/nginx/sbin/nginx-s reload
The above describes how to configure https for nginx, including some content, and hope to help those who are interested in the PHP Tutorial.