Nginx Installation and Configuration

Environment: CentOS 7.5

  1. install the dependencies
yum install openssl
yum install zlib
yum install pcre
  1. install nginx repository
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  1. install nginx
yum install nginx
  1. start nginx
sudo systemctl start nginx
  1. nginx can be visited via http://youripaddress
  2. the default port is 80. it can be modified by editing the file under /etc/nginx/conf.d/default.conf

Https configuration

  1. open file under /etc/nginx/conf.d/default.conf
  2. 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;
    }
}
  1. restart nginx service
sudo systemctl restart nginx
  1. visit https://youripaddress

Configure reverse proxy

  1. edit the file under /etc/nginx/conf.d/default.conf
location /subdomain {
        proxy_pass https://youripaddress:port/subdomain
}
2. restart nginx service



©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容