nginx

OAuth Callback URL incompatible with nginx proxy server behavior

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-31 09:47:09
问题 I have spent a good part of the last 3 days trying every solution that is on the internet and feeling desperate. Here's the problem statement: I have a Dockerized app with three services: A django application with gunicorn ( web ) A Nginx server ( nginx ) PostgreSQL ( db ) My web application requires user to log in with their GitHub account through a fairly standard OAuth process. This has always worked without nginx . User clicks on the "log in with github" button, sent them to GitHub to

理解HTTP之keep-alive

可紊 提交于 2020-12-31 08:53:17
理解HTTP之keep-alive 在前面一篇文章中讲了 TCP的keepalive ,这篇文章再讲讲HTTP层面keep-alive。两种keepalive在拼写上面就是不一样的,只是发音一样,于是乎大家就都迷茫了。HTTP层面的keep-alive是我们接触比较多的,也是大家平时口头上的"keepalive"。下面我们就来谈谈HTTP的keep-alive 短连接&长连接&并行连接 再说keep-alive之前,先说说HTTP的短连接&长连接。 短连接 所谓短连接,就是每次请求一个资源就建立连接,请求完成后连接立马关闭。每次请求都经过“创建tcp连接->请求资源->响应资源->释放连接”这样的过程 长连接 所谓长连接(persistent connection),就是只建立一次连接,多次资源请求都复用该连接,完成后关闭。要请求一个页面上的十张图,只需要建立一次tcp连接,然后依次请求十张图,等待资源响应,释放连接。 并行连接 所谓并行连接(multiple connections),其实就是并发的短连接。 keep-alive 具体client和server要从短连接到长连接最简单演变需要做如下改进: client发出的HTTP请求头需要增加Connection:keep-alive字段 Web-Server端要能识别Connection:keep-alive字段

How to run bash script from Nginx

亡梦爱人 提交于 2020-12-31 06:44:47
问题 1) I have static site and wand to set "autopull" from bitbucket. 2) I have webhook from bitbucket. 3) I have bash script which do "git pull" How can I run this script when nginx catch request? server { listen 80; server_name example.ru; root /path/to/root; index index.html; access_log /path/to/logs/nginx-access.log; error_log /path/to/logs/nginx-error.log; location /autopull { something to run autopull.sh; } location / { auth_basic "Hello, login please"; auth_basic_user_file /path/to/htpasswd

通过源码理解http层和tcp层的keep-alive

佐手、 提交于 2020-12-31 06:04:45
前言:最近在研究websocket和keep-alive。而websocket涉及到长连接,过多无用的长连接对系统来说是负担,是否可以尽快发现对端是否已经掉线,从而释放这个连接来减少系统压力呢,就这个初衷,通过wireshark和nodejs调试一下心跳机制。引发了一些研究和思考。 我们知道建立tcp连接的代价是比较昂贵的,每次连接需要三次握手,还有慢开始,或者建立一个连接只为了传少量数据等都影响了效率。这时候如果能保持连接,那会大大提高效率。但是如果一直保持连接,又没有数据或者有一端已经断网则会浪费资源,如何做到一个相对的取舍呢?本文通过源码来分析一下关于keep-alive的原理。读完本文,相信你会对这个问题有更多的理解。本文分成两个部分 1 http层的keep-alive 2 tcp层的keep-alive 1 http层的keep-alive 最近恰好在看nginx1.17.9,我们就通过nginx来分析。我们先来看一下nginx的配置。 keepalive_timeout timeout; keepalive_requests number; 上面两个参数告诉nginx,如果客户端设置了connection:keep-alive头。nginx会保持这个连接多久,另外nginx还支持另外一个限制,就是这个长连接上最多可以处理多少个请求。达到阈值后就断开连接

How can I redirect non-www to www in https NGINX

帅比萌擦擦* 提交于 2020-12-31 06:01:40
问题 I have a question related with Nginx redirects Bellow you can see configurations. My goal is to redirect from https://example.com to https://www.example.com I looked through almost all in stackoverflow and I didn't find any help. Please help me with this issue. I will provide all necessary information about my Nginx Web Server. I hope you will help me, with this difficult question. My file nginx.conf looks like there: user www-data; worker_processes 4; pid /run/nginx.pid; events { worker

CORS issue with Django and React hosted on same server

为君一笑 提交于 2020-12-31 05:28:17
问题 I am having a CORS issue with my Django Rest Framework and React app on the same server. I am running Vagrant with an Ubuntu 18 box and NGINX installed (I am assuming this issue will translate to DigitalOcean) I apologize ahead of time if I am providing too much information. DRF is using Supervisor and Gunicorn is on port 8000. I created my React app using create-react-app. I then used npm run build to create the static files. NGINX Setup: React Conf server { listen 8080; server_name sandbox

CORS issue with Django and React hosted on same server

倖福魔咒の 提交于 2020-12-31 05:27:45
问题 I am having a CORS issue with my Django Rest Framework and React app on the same server. I am running Vagrant with an Ubuntu 18 box and NGINX installed (I am assuming this issue will translate to DigitalOcean) I apologize ahead of time if I am providing too much information. DRF is using Supervisor and Gunicorn is on port 8000. I created my React app using create-react-app. I then used npm run build to create the static files. NGINX Setup: React Conf server { listen 8080; server_name sandbox

CORS issue with Django and React hosted on same server

倖福魔咒の 提交于 2020-12-31 05:27:05
问题 I am having a CORS issue with my Django Rest Framework and React app on the same server. I am running Vagrant with an Ubuntu 18 box and NGINX installed (I am assuming this issue will translate to DigitalOcean) I apologize ahead of time if I am providing too much information. DRF is using Supervisor and Gunicorn is on port 8000. I created my React app using create-react-app. I then used npm run build to create the static files. NGINX Setup: React Conf server { listen 8080; server_name sandbox

在kubernetes集群中部署php应用

时光总嘲笑我的痴心妄想 提交于 2020-12-30 21:05:09
本文将介绍在kubernetes环境中部署一套php应用系统。前端web采用nginx、中间件php以fastcgi的方式运行,后台数据库由mysql主从提供支撑。 各服务组件之间的调用采用dns解析服务名的方式进行,数据和配置文件持久化采用pv和pvc(基于nfs)。 一、通过dockerfile创建php镜像文件 # cat dockerfile FROM docker.io/openshift/base-centos7:latest MAINTAINER ylw "ylw@fjhb.cn" RUN yum makecache RUN yum -y install php-fpm php php-gd php-mysql php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php-xmlrpc RUN sed -i 's/listen = 127.0.0.1:9000/listen = 0.0.0.0:9000/' /etc/php-fpm.d/www.conf RUN sed -i 's/listen.allowed_clients = 127.0.0.1/;listen.allowed_clients = 127.0.0.1/' /etc/php-fpm.d/www.conf EXPOSE 9000 CMD

开源API网关Kong基本介绍和安装验证

南笙酒味 提交于 2020-12-30 17:02:01
本文将介绍开源API网关Kong。在GtiHub搜索API网关类的开源产品,可以看到Kong网关常年都是排第一的位置,而且当前很多都有一定研发能力的企业在API网关产品选型的时候基本也会选择Kong网关,并基于Kong网关进行二次开发和定制。 API网关概述 简单来说API网关就是将所有的微服务提供的API接口服务能力全部汇聚进来,统一接入进行管理,也正是通过统一拦截,就可以通过网关实现对API接口的安全,日志,限流熔断等共性需求。如果再简单说下,通过网关实现了几个关键能力。 内部的微服务对外部访问来说位置透明,外部应用只需和网关交互 统一拦截接口服务,实现安全,日志,限流熔断等需求 从这里,我们就可以看到API网关和传统架构里面的ESB总线是类似的,这些关键能力本身也是ESB服务总线的能力,但是ESB服务总线由于要考虑遗留系统的接入,因此增加了: 大量适配器实现对遗留系统的遗留接口适配,多协议转换能力 进行数据的复制映射,路由等能力 对于两者,我原来做过一个简单的对比,大家可以参考。 对于API网关进一步的功能介绍,可以我前面参考文章:《 一文详细讲解API网关核心功能和API管理扩展 》。 基于Openresty开发API网关 在谈API网关前,我们先谈下Openresty。在前面文章谈到过,当前适合用于API网关的架构,一种是基于Openresty的,一种是基于Go语言的。