This is notes for CentOS 6.9 with Oracle Apex running on port 8080.
1. Install Ngnix with root login
# yum install epel-release
# yum install nginx
# service nginx start
# chkconfig nginx on
Three things to ensure before this.
- there is an A record in your DNS server which is pointing to this machine (e.g. apex.yourdomain.com pointing to a external fixed ip address)
- if your machine is behind firewall and using private ip address, make sure you have proper Virtual Server setting. Try to map external ports 80 and 443 to internal 188.4.72.11:80 and 443.
- if your machine is behind firewall and using private ip address, make sure you have proper dedicated NAT for this server outgoing packet.
Testing to ensure it works,
- ping apex.yourdomain.com from any external machine and make sure it resolve the true ipaddress, it doesn’t matter if ping time out.
- run the following command to make sure all outgoing packets are using true ip address
# dig +short myip.opendns.com @resolver1.opendns.com
make sure the displayed ip address is same as that on step 1.
Now you can install Certbot
login as root
# cd /root
# wget https://dl.eff.org/certbot-auto
# chmod a+x certbot-auto
# chmod a+x certbot-auto
Then generate the certificate for NGINX
# /root/certbot-auto --nginx certonly
3. config the cert for nginx
# vi /etc/nginx/conf.d/ssl.conf
add following lines to the file
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/apex.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/apex.yourdomain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
4. restart nginx
# service nginx restart
now you can use https://apex.yourdomain.com
5. setup Reverse proxy for apex
# cd /etc/nginx/conf.d/ssl.conf
add following lines within server {} block
location / {
# Fix the "It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8080;
proxy_read_timeout 90;
proxy_redirect http://localhost:8080/apex https://apex.yourdomain.com/apex;
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;
}
# service nginx restart
now you can use https://apex.yourdomain.com/apex
No comments:
Post a Comment