[root@nginxprxy tmp]# yum -y install nginx-release-rhel-6-0.el6.ngx.noarch.rpm [root@nginxprxy tmp]# yum install -y nginx
Configuración del proxy reverso con ssl
server {
listen 80;
return 301 https://$host$request_uri;
}
# HTTPS server
#
server {
listen 443;
server_name service.enterprise.com;
ssl_certificate /etc/nginx/certs/service.enterprise.com.crt;
ssl_certificate_key /etc/nginx/certs/service.enterprise.comm.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/service.access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://unsecureservice.enterprise.com;
proxy_read_timeout 90;
proxy_redirect http://unsecureservice.enterprise.com https://service.enterprise.com;
}
}
Por último se establecen las reglas de redirección del proxy de forma que todo lo que entre a través de la URL https://service.enterprise.com; lo redirija a la http://unsecureservice.enterprise.com.
[root@nginxprxy tmp]# cd /etc/nginx/
[root@nginxprxy tmp]# mkdir certs
[root@nginxprxy certs]# openssl req -new -newkey rsa:2048 -nodes -keyout service.enterprise.com.key -out service.enterprise.com.csr
Generating a 2048 bit RSA private key
……………………………………….+++
…+++
writing new private key to ‘service.enterprise.com.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) [XX]:XX
State or Province Name (full name) []:XXXX
Locality Name (eg, city) [Default City]:XXXX
Organization Name (eg, company) [Default Company Ltd]:XXXX
Organizational Unit Name (eg, section) []:XXXX
Common Name (eg, your name or your server’s hostname) []:service.enterprise.com
Email Address []:XXXX@enterprise.com
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Una vez obtengamos el certificado deberemos crear el fichero crt con el contenido del certificado:
[root@nginxprxy certs]# vi service.enterprise.com.crt —–BEGIN CERTIFICATE—– MIIFWjCCBEKgAwIBAgIDCmMEMA0GCSqGSIb3DQEBBQUAMGExCzAJBgNVBAYTAlVT…8WjFirPK7+2Gbq+9w4DpJ+a5FJjTOKfcRvIrZION
—–END CERTIFICATE—–
[root@nginxprxy conf.d]# service nginx stop Stopping nginx: [FAILED] [root@nginxprxy conf.d]# service nginx start Starting nginx: [ OK ]