Skip to content

ninghao/nginx-conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Nginx Configuration

Install Nginx

CentOS

Create a file named /etc/yum.repos.d/nginx.repo with following contents:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

To install nginx, run the following command:

yum install nginx

SSL

CentOS

Install Certbot

yum install certbot python2-certbot-nginx

Install certificates

certbot --nginx

or

certbot certonly --nginx

Auto renewal

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew" | sudo tee -a /etc/crontab > /dev/null

Fix error

If you encounter this error: "ImportError: No module named 'request-packages.urllib3'", execute following commands:

pip uninstall urllib3
yum install python-urllib3 -y
pip uninstall requests
yum remove python-requests
yum install python-requests -y
yum install certbot -y
yum install python2-certbot-nginx -y

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published