rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
chkconfig nginx on
vi /etc/nginx/nginx.conf
: worker_processes 2; : gzip on; include /etc/nginx/conf.d/*.conf; }
vi /etc/nginx/conf.d/default.conf
server { listen 80; server_name localhost; :
vi /etc/nginx/conf.d/abc_ichiayi.conf
server { server_name abc.ichiayi.com abc1.ichiayi.com; access_log /var/log/nginx/abc.ichiayi.com.access.log main; error_log /var/log/nginx/abc.ichiayi.com.error.log; location / { set_real_ip_from 192.168.11.0/24; real_ip_header X-Forwarded-For; real_ip_recursive on; proxy_pass http://192.168.11.233:80; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /292/ { proxy_pass http://192.168.11.292/; } }
vi /etc/nginx/conf.d/xyz_ichiayi.conf
server { server_name xyz.ichiayi.com; access_log /var/log/nginx/xyz.ichiayi.com.access.log main; error_log /var/log/nginx/xyz.ichiayi.com.error.log; location / { set_real_ip_from 192.168.11.0/24; real_ip_header X-Forwarded-For; real_ip_recursive on; proxy_pass http://192.168.11.232:80; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
server { listen 192.168.1.2:80 default_server; server_name example.com www.example.com; ... }
: listen 443 ssl default_server; :
server { server_name ichiayi.com www.ichiayi.com; : : ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = www.ichiayi.com) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = ichiayi.com) { return 301 https://www.ichiayi.com$request_uri; } listen 80 default_server; server_name ichiayi.com www.ichiayi.com; return 404; # managed by Certbot }
然後重新啟動 nginx
systemctl restart nginx