Environment: CentOS 7.5
- install the dependencies
yum install openssl
yum install zlib
yum install pcre
- install nginx repository
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- install nginx
yum install nginx
- start nginx
sudo systemctl start nginx
- nginx can be visited via http://youripaddress
- the default port is 80. it can be modified by editing the file under /etc/nginx/conf.d/default.conf
Https configuration
- open file under /etc/nginx/conf.d/default.conf
- edit the file, add the code below to the bottom of the file
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
- restart nginx service
sudo systemctl restart nginx
- visit https://youripaddress
Configure reverse proxy
- edit the file under /etc/nginx/conf.d/default.conf
location /subdomain {
proxy_pass https://youripaddress:port/subdomain
}
2. restart nginx service
网友评论