验证中...
助力高校计算机教育 —— 码云为老师推出免费高校版,高达 200 人的协作团队
语言: 其他
分类: 网络技术
最后更新于 2018-06-14 17:31
nginx.conf
原始数据 复制代码
yum update
yum install -y gcc-c++
yum install -y openssl openssl-devel
yum install -y zlib zlib-devel
yum install -y nginx
cd /etc/nginx/conf.d
vim my.conf
server {
listen 80;
server_name 127.0.0.1;
access_log off;
root /web;
index index.html index.htm index.php;
if ( !-e $request_filename){
rewrite ^/(.+)$ /index.php/$1 last;
}
location ~ ^(.+\.php)(.*)$ {
root /web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
include fastcgi.conf;
}
}
cd /
mkdir web
cd web
vim index.html
centos6
设置开机启动
chkconfig nginx on
开启nginx
service nginx start
service nginx stop
service nginx restart
centos7
开启nginx
systemctl start nginx
设置开机启动
systemctl enable nginx
停止开机自启动
systemctl disable nginx
查看服务当前状态
systemctl status nginx
重新启动服务
systemctl restart nginx
server {
listen 80 default;
listen 443 ssl;
server_name test.cn;
ssl_certificate /etc/letsencrypt/live/test.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.cn/privkey.pem;
反向代理
server {
listen 80;
server_name test.cn;
index index.html index.htm index.php;
root /data/web/;
access_log off;
location / {
#if ( !-e $request_filename ){
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
proxy_set_header Scheme $scheme;
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 ^~ /static/ {
root /data/web/;
}
}
SSL第一种
https://certbot.eff.org/lets-encrypt/centos6-nginx
yum install git
git clone https://github.com/certbot/certbot
cd certbot
./letsencrypt-auto certonly --standalone --email test@163.com -d test.cn
SSL第二种安装
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto --nginx //不知道要不要
service nginx stop
生成证书
./certbot-auto certonly --standalone --email `你的邮箱地址` -d `你的域名地址`
当前网站有多个域名时需在后面增加,例如
./certbot-auto certonly --standalone --email `你的邮箱地址` -d `你的域名1` -d `你的域名2`
查看生产的证书
cd /etc/letsencrypt/
证书用于nginx
在nginx网站配置文件中增加
# TLS 基本设置 ssl_certificate /etc/letsencrypt/live/www.just4fun.site/fullchain.pem;#证书位置 ssl_certificate_key /etc/letsencrypt/live/www.just4fun.site/privkey.pem;# 证书位置
启动nginx
证书续签
./certbot-auto renew

评论列表( 0 )

你可以在登录后,发表评论

10_float_left_people 10_float_left_close