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; ...
随机推荐
- js 带有返回值的 匿名方法
//可以给 permissionField返回'a,b,c'这样的以逗号分隔的字符串 permissionField:(function(){ var arr = []; $("input[ ...
- init, telinit - 进程处理初始化
总览 /sbin/init [ -a ] [ -s ] [ -b ] [ -z xxx ] [ 0123456Ss ] /sbin/telinit [ -t 秒 ] [ 0123456sSQqabcU ...
- Tomb Raider HihoCoder - 1829 (二进制枚举+暴力)(The 2018 ACM-ICPC Asia Beijing First Round Online Contest)
Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her ...
- 深入理解JAVA虚拟机 虚拟机性能监控和故障处理工具
jre的bin目录下的工具,都非常小.它都是tools.jar下面的代码的一层封装而已.tools.jar不是java标准,是Hotspot实现的. 名称 作用 jps JVM Process Sta ...
- bash: ipconfig: command not found
问题描述: [root@localhost ~]# ipconfig-bash: ipconfig: command not found[root@localhost ~]# 解决方法一: cd /e ...
- EM算法理解的九层境界
EM算法理解的九层境界 EM 就是 E + M EM 是一种局部下限构造 K-Means是一种Hard EM算法 从EM 到 广义EM 广义EM的一个特例是VBEM 广义EM的另一个特例是WS算法 广 ...
- 【NOIP2016提高A组模拟9.9】闭门造车
题目 自从htn体验了一把飙车的快感,他就下定决心要闭门造车!但是他两手空空怎么造得出车来呢?无奈的他只好来到了汽车零部件商店. 一走进商店,玲琅满目的各式零件看得htn眼花缭乱.但是他很快便反应过来 ...
- Electron开发使用Vue Devtools
转自 [https://orchidflower.oschina.io/2017/03/29/Using-Vue-Devtools-in-Electron/] 2.2 安装步骤 首先在Chrome中安 ...
- ETL工具之kittle使用案例整理
主花了一下午时间,收集全网,学习了下kittle,觉得该大v写的不错,特意整理给大家!学会这几个案例kittle基本就没问题了. 1.kettle案例一抽取gz格式文本内容保存到mongodb ht ...
- 实战build-react(一)
https://www.jianshu.com/p/34468f13263c(copy) 目录结构 一.安装 npm install -g create-react-app 二.创建react应用 ...