4、赋予权限并增加到系统服务
sudo chmod +x ./nginx sudo update-rc.d nginx defaults
三、修改默认的 nginx.conf 配置文件
默认官方的配置文件写的很简单,这里我们也模仿 Ubuntu 14.04 官方源修改一个适合我们的 Nginx 配置QrR免费翻墙网
1、编辑 /etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
具体内容如下:QrR免费翻墙网
worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; proxy_temp_file_write_size 128k; proxy_temp_path /var/cache/nginx/temp; proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache_one:100m inactive=7d max_size=10g; gzip_static on; gzip on; gzip_disable "msie6"; include /etc/nginx/sites-enabled/*; }
2、新建几个必要的文件夹
其中 /etc/nginx/sites-enabled 用来放我们的网站配置文件,/var/log/nginx 用来放 log 日志文件,/var/cache/nginx/cache 和/var/cache/nginx/temp 则是 Nginx 反代缓存文件夹。QrR免费翻墙网
mkdir -p /etc/nginx/sites-enabled mkdir -p /var/log/nginx mkdir -p /var/cache/nginx/cache mkdir -p /var/cache/nginx/temp
3、检查 Nginx 配置
直接运行 nginx -t 如果输出如下提示,则一切正常QrR免费翻墙网
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
四、开启 Nginx SSL 支持
1、为了管理方便,我们建立个 ssl 目录
mkdir -p /root/ssl && cd /root/ssl
2、运行下面的命令,生成 example.com.key 和 example.com.csr
openssl req -new -newkey rsa:2048 -nodes -out example.com.csr -keyout example.com.key -subj "/C=US/ST=CA/L=Los Angeles/O=Example Inc./OU=Web Security/CN=example.com"
如果是泛域名证书,最后的域名改成 *.example.com QrR免费翻墙网
3、然后把 csr 文件提交给你的 SSL 证书商
验证好域名以后会颁发给你一个 .crt 文件,我们命名为 example.com.crt QrR免费翻墙网
4、接着我们新建一个配置文件,用来反代 Google
请自行更换配置文件里的域名和证书文件名QrR免费翻墙网
vi /etc/nginx/sites-enabled/google.conf
具体配置如下QrR免费翻墙网
server { listen 80; server_name example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl; server_name example; ssl on; ssl_certificate /root/ssl/example.com.crt; ssl_certificate_key /root/ssl/example.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM; keepalive_timeout 70; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; resolver 8.8.8.8; location / { google on; google_scholar "scholar.google.com"; } }
3/6 首页 上一页 1 2 3 4 5 6 下一页 尾页
|