nginx请求转发配置
以下为无ssl证书配置的请求转发
server {
listen ;
server_name api.****.com;
#以下为指定请求域名匹配到某一个端口
#location ~* /union {
#以下为全部转发到某一个端口
location / {
client_max_body_size 3000m;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
proxy_connect_timeout ;
if ($http_origin ~ https://(.*).****.com){
set $allow_url $http_origin;
}
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, HEAD";
# add_header Access-Control-Allow-Origin $allow_url;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Cookie,Set-Cookie,Origin,X-Requested-With,token,authorization,Accept,Content-type";
add_header Access-Control-Allow-Credentials "true";
add_header Content-Type "text/plain; charset=utf-8";
add_header Content-Length ;
return ;
}
}
}
以下为有ssl请求转发
server {
listen ;
server_name api.****.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen ;
server_name api.****.com;
ssl on;
ssl_certificate /etc/nginx/cert/api.pem;
ssl_certificate_key /etc/nginx/cert/api.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. TLSv1.;
ssl_prefer_server_ciphers on;
#以下为指定请求域名匹配到某一个端口
#location ~* /union {
#以下为全部转发到某一个端口
location / {
client_max_body_size 3000m;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
proxy_connect_timeout ;
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, HEAD";
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Cookie,Set-Cookie,Origin,X-Requested-With,token,authorization,Accept,Content-type";
add_header Access-Control-Allow-Credentials "true";
add_header Content-Type "text/plain; charset=utf-8";
add_header Content-Length ;
return ;
}
}
}
nginx请求转发配置的更多相关文章
- Nginx 路由转发配置(转)
Nginx 路由转发配置笔记 由于预算有限,只有一台服务器,想要玩的东西不少,所以这个台服务器上会提供多重服务,因此涉及到的nginx转发就必有重要了 由nginx做请求代理,提供多种服务 php搭建 ...
- Nginx请求限制配置
Nginx请求限制配置 请求限制可以通过两种方式来配置,分别是 连接频率限制和请求频率限制 首先我们要知道什么是http请求和连接,浏览器和服务端首先通过三次握手完成连接,然后发起请求,传输请求参数 ...
- Struts2中重定向和请求转发配置
struts2中默认跳转为dispatcher请求转发 只能往jsp转发,跳转action报404 重定向 设置为redirect ,可以是jsp也可以是action <!--同一个包下的act ...
- Nginx请求转发
1.比如说我要将127.0.0.1/topics上的所有请求转发到xxx:xxx/上 修改 sudo vim /etc/nginx/nginx.conf server { listen 80; ser ...
- nginx 端口转发配置
nginx.conf #user nobody; worker_processes ; #error_log logs/error.log; #error_log logs/error.log not ...
- Nginx配置TCP请求转发
Nginx配置TCP请求转发 1.TCP请求转发基于stream在1.9版本前,需要单独编译安装该组建: # 依赖服务 [root@baolin conf]#yum -y install pcre-d ...
- 在nginx配置将请求转发到某个真实后端服务ip
一.打开nginx机器的nginx配置文件 命令: locate nginx.conf 会列出所有nginx.conf文件的地址, 一般咱们要用的nginx配置文件是/usr/local/nginx/ ...
- nginx实现请求转发
反向代理适用于很多场合,负载均衡是最普遍的用法. nginx 作为目前最流行的web服务器之一,可以很方便地实现反向代理. nginx 反向代理官方文档: NGINX REVERSE PROXY 当在 ...
- nginx学习(2):启动gzip、虚拟主机、请求转发、负载均衡
一.启用gzip gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; ...
随机推荐
- CF1090H Linearization
传送门 先考虑什么样的串才符合条件.\(s_i=P(x\&i)\oplus b\),其实这里的\(b\)只能使得整体是否取反,所以可以先不管.然后考虑\(x\)的每个二进制位的对\(s_0\) ...
- SpringBoot项目中遇到的BUG
1.启动项目的时候报错 1.Error starting ApplicationContext. To display the auto-configuration report re-run you ...
- docker常用技巧
1:运行中容器如何保存为一个镜像? docker commit 容器名字 镜像名字 2:怎么给容器增加名字 docker rename 容器id(或名字)name(新名字) 3:docker中的Doc ...
- 一、core 启动设置文件中的错误(启动文件不存在)
一.启动文件不存在 查看 别人的 原因是
- 爬虫笔记八——Scrapy实战项目
(案例一)手机App抓包爬虫 1. items.py import scrapy class DouyuspiderItem(scrapy.Item): # 存储照片的名字 nickName = sc ...
- AI换脸教程:DeepFaceLab使用教程(1.安装及分解视频)
首先需要选择合适的DeepFaceLab下载(https://www.deepfacelabs.com/list-5-1.html),然后安装相应的显卡驱动,如果已经准备好这些工作,那么恭喜你,终于开 ...
- Python之常用模二(时间、序列号等等)
一.time模块 表示时间的三种方式: 时间戳:数字(计算机能认识的) 时间字符串:t='2012-12-12' 结构化时间:time.struct_time(tm_year=2017, tm_mon ...
- mysql慢查询分析
mysql慢查询分析 Posted: 29. 08. 2014 | Author: zdz | Category: mysql MySQL 慢查询日志分析 1. pt-query-digest分析慢查 ...
- NOIP2016提高A组五校联考3总结
第一题,本来一开始就想到了数位dp,结果脑残地打了十几个转移方程,总是调试不出来,一气之下放弃了. 调第一题几乎调了整节比赛,第二第三都没它. 第二题连边找联通块. 第三题题解都打了三页,看都不想看. ...
- 伸展树splay之求区间极值
前言 这篇博客是根据我在打这道题的时候遇到的问题,来打的,有些细节可能考虑不到. 题目 在N(1<=N<=100000)个数A1-An组成的序列上进行M(1<=M<=10000 ...