版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
了解一下nginx反向代理。觉得很优秀。
首先简单代理。没啥说的。
代理到我的8001端口上。不用测试。指定好使。
然后尝试代理80端口
我日?nginx启动不了。什么鬼。
好吧。弱智问题。我的服务器安装了IIS。果断卸掉IIS。
启动。ok 非常可以
接下来我们来试试代理443接口
上配置
运行访问上图
上请求
好吧。这么写好像不太行。虽然代理过来了。但是这个443好像不对
哈哈。开玩笑了。百度一下。443代理
修改配置文件
上页面访问
我可真是优秀,请求一下看看
ok请求成功。
下面咱们代理一个国外网站看看
什么鬼?怎么回事?和我搞事情。。。
发现了一个502.之前还真从来没见过这个
查一下nginx日志
好吧。告诉我ssl握手失败。这是什么鬼。
查一查。发现一篇大神文章
https://tyloafer.github.io/posts/34556/ 非常感谢
SSL的问题,代理的时候加一下SSL处理
上配置文件
开始访问下看看
okok真是优秀
好像到这只是能代理过来页面。但是好像哪里还出现了问题。导致页面一直再请求。
留待以后研究
其实我最开始的目的只是为了代理这个网站提供的API
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#server {
# listen 443;
#server_name www.asqmkj.com;
#charset koi8-r;
#access_log logs/host.access.log main;
# location / {
#index index.html index.htm;
#proxy_pass http://120.27.16.5:3000;
# proxy_pass https://dcetest.wegoaldx.com;
# add_header Access-Control-Allow-Origin *;
# add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
# }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root html;
# }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
# }
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 443;
server_name musement.dlanqi.com;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/2249723_musement.dlanqi.com.pem;
ssl_certificate_key cert/2249723_musement.dlanqi.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_ssl_server_name on;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
proxy_set_header Accept-Encoding "none";
proxy_pass https://sandbox.musement.com/;
sub_filter 'https://m.cn.nytimes.com' 'https://www.xxx.com/';
sub_filter 'd1f1eryiqyjs0r.cloudfront.net' 'www.xxx.com/d1f1eryiqyjs0r';
sub_filter_once off;
}
}
}
——————————————————————————————————
作者:Henny_CHN
转载请标明出处,原文地址:
https://blog.csdn.net/a1234012340a/article/details/90482899
如果感觉本文对您有帮助,请留下您的赞,您的支持是我坚持写作最大的动力,谢谢!