Nginx的rewrite模块疑问排查
[ root@nginxagent ~ ]#mkdir /etc/nginx/ssl#----------------------------------生成自签名秘钥和证书------------
[ root@nginxagent ~ ]#cd /etc/pki/tls/certs
[ root@nginxser01 certs ]#make nginx.crt
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > nginx.key
Generating RSA private key, 2048 bit long modulus
.........+++
.........................................+++
e is 65537 (0x10001)
Enter pass phrase: #创建私钥,并输入密码#
Verifying - Enter pass phrase: #确认密码#
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key nginx.key -x509 -days 365 -out nginx.crt -set_serial 0
Enter pass phrase for nginx.key: #利用私钥生成证书,输入私钥密码#
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) :CN
State or Province Name (full name) []:SHANXI
Locality Name (eg, city) :XI'AN
Organization Name (eg, company) :JNCSY
Organizational Unit Name (eg, section) []:OPT
Common Name (eg, your name or your server's hostname) []:www.a.com
Email Address []:
#-------------------------验证生成的证书和秘钥------------------------------
[ root@nginxser01 certs ]#ll ngi*
-rw------- 1 root root 1289 Oct 28 06:47 nginx.crt
-rw------- 1 root root 1766 Oct 28 06:43 nginx.key
#-------------------------避免每次调用私钥进行输入密码验证进行解密-----------
[ root@nginxser01 certs ]#openssl rsa -in nginx.key -out nginx.key
Enter pass phrase for nginx.key:
writing RSA key
[ root@nginxser01 certs ]#cp ngi* /etc/nginx/ssl
[ root@nginxagent conf.d ]#vim virtual.conf
#server test
server {
listen 80;
index index.html;
server_name www.a.com;
root /app/website01/;
location / {
rewrite ^/(.*)$https://172.18.27.22/$1 redirect;
}
server {
listen 443 ssl;
server_name www.a.com;
index index.html;
root /app/website01/;
ssl on;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
ssl_session_cache builtin:1000 shared:SSL:20m;
ssl_session_timeout 10m;
}
页:
[1]