nginx 配置 google代理

准备的东西
1.一个可以访问google的vps,推荐搬瓦工,120rmb/Y
2.一个垃圾域名(已经解析到该vps的ip),被封不心疼
3.nginx
4.ssl证书 ,可以使用xx免费一年的

1.easy模式,不需要ssl证书
tips: 听说有时候会被定向到google.com

server
{
listen 80;
server_name example.com; #你的域名
location / {
proxy_pass http://www.google.com/; #需要反代的域名
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

2.ssl证书
server {
listen 80;
server_name example.com www.example.com;
location / {
rewrite ^/(.*)$ https://example.com$1 permanent;
}
}
server {
listen 443 ssl http2 default_server;
ssl on;

server_name www.example.com;
ssl_certificate 1_www.example.com_bundle.crt;
ssl_certificate_key 2_www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass https://www.google.com;
sub_filter www.google.com www.example.com;
sub_filter_once off;
}

参考自:
https://hack0nair.me/2014-10-25-how-to-setup-reverse-proxy-by-nginx/
https://blog.kings-way.info/?p=689
https://www.v2ex.com/t/202435
https://www.qcloud.com/document/product/400/4143#2.-nginx-.E8.AF.81.E4.B9.A6.E9.83.A8.E7.BD.B2

配置nginx
https://mos.meituan.com/library/21/initial-setup-with-centos/
https://mos.meituan.com/library/18/how-to-install-lnmp-on-centos7/

第一步,在/etc/yum.repos.d/目录下创建一个源配置文件nginx.repo:
cd /etc/yum.repos.d/
vim nginx.repo
填写如下内容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存,则会产生一个/etc/yum.repos.d/nginx.repo文件。
下面直接执行如下指令即可自动安装好Nginx:
yum install nginx -y
安装完成,下面直接就可以启动Nginx了:
/etc/init.d/nginx start
现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。
如果还无法访问,则需配置一下Linux防火墙。
iptables -I INPUT 5 -i eth0 -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT
service iptables save
service iptables restart
Nginx的命令以及配置文件位置:
/etc/init.d/nginx start # 启动Nginx服务
/etc/init.d/nginx stop # 停止Nginx服务
/etc/nginx/nginx.conf # Nginx配置文件位置
chkconfig nginx on #设为开机启动
至此,Nginx已经全部配置安装完成。
一台主机上适应多个服务器:
在你的nginx通过代理的方式转发请求:配置如下
vi /etc/nginx/nginx.conf
在http加入下面的内容,参考:http://wiki.nginx.org/FullExample
http {
.
server {
listen 80;
server_name www.a.com;
charset utf-8;
access_log /home/a.com.access.log main;
location / {
proxy_pass http://127.0.0.1:80;
}
}
server {
listen 80;
server_name www.b.com;
charset utf-8;
access_log /home/b.com.access.log main;
location / {
proxy_pass http://127.0.0.1:81;
}
}
...

view raw
centos6.5_nginx
hosted with ❤ by GitHub

配置 ftp
http://pcvc.net/blog/2015/08/09/centos-7-installation-configuration-do-vsftpd-ftp-service/
———————

原文:https://blog.csdn.net/u010403842/article/details/54773795

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.