首页 > 系统相关 >ubuntu 18 源码安装nginx

ubuntu 18 源码安装nginx

时间:2023-03-29 16:48:53浏览次数:44  
标签:http 18 module nginx 源码 proxy timeout connect

linux 搭建 nginx正向代理 , 添加  第三方模块ngx_http_proxy_connect_module

apt-get install build-essential
apt-get install libtool
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev
apt-get install openssl
apt-get install libssl-dev

cd /usr/local
wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar -xf  nginx-1.20.1.tar.gz
wget https://github.com/chobits/ngx_http_proxy_connect_module/archive/refs/heads/master.zip
unzip  master.zip
cd  nginx-1.20.1

patch -p1 < /usr/local/ngx_http_proxy_connect_module-master/patch/proxy_connect_rewrite_101504.patch

./configure \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--add-module=/usr/local/ngx_http_proxy_connect_module-master

make && make install

cd /usr/local/nginx/sbin
./nginx  启动nginx
./nginx -s stop  关闭nginx
./nginx -s reload  重启nginx

填加nginx 配置文件,实现nginx 正向代理
worker_processes  auto;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    proxy_set_header HOST $host;
    proxy_buffers 256 4k;
    proxy_max_temp_file_size 1000k;
    proxy_connect_timeout 300;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    proxy_next_upstream error timeout invalid_header http_502;
############################################################
   # 配置http正向代理
   server {
        resolver 4.2.2.2;      #指定DNS服务器IP地址
        listen 8000;
        server_name  47.251.**.**;
        location / {
     
           proxy_pass http://$host$request_uri;     #设定代理服务器
           proxy_set_header Host $host;

    }
}
############################################################
   # 配置https正向代理
   server {
        resolver 4.2.2.2;       #指定DNS服务器IP地址
        listen 4430;
        server_name  47.251.**.**;
        location / {
     
           proxy_pass https://$host$request_uri;    #设定代理服务器的协议和地址
           proxy_set_header Host $host;

    }
}
############################################################
   server {

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }



server{
    listen 8080;
    resolver 4.2.2.2 4.2.2.6;
    resolver_timeout 30s;
    proxy_connect;
    proxy_connect_allow 80 443;
    proxy_connect_timeout 10;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    location / {
        proxy_pass https://api.openai.com/v1/models;
        proxy_set_header Host $host;
    }
}
}

 

 

标签:http,18,module,nginx,源码,proxy,timeout,connect
From: https://www.cnblogs.com/zyl88/p/17269456.html

相关文章

  • 后端手册--18--redis缓存
    Redis缓存yudao-spring-boot-starter-redis (opensnewwindow)技术组件,使用Redis实现缓存的功能,它有2种使用方式:编程式缓存:基于SpringDataRedis框架的Redi......
  • 源码分析CHANGE REPLICATION SOURCE TO
    从MySQL8.0.23版本开始,CHANGEMASTERTO开始被替换为CHANGEREPLICATIONSOURCETO,下面使用MySQL8.0.32的代码分析语句的具体执行流程。从语句的入口函数mysql_execute_......
  • ingress-nginx的日志落地
    配置Nginx-Ingress这里将NG的日志落盘,便于处理。(1)、修改ConfigMap,如下:#Source:ingress-nginx/templates/controller-configmap.yamlapiVersion:v1kind:ConfigMap......
  • k8s的 Nginx Ingress 调优
    内核参数调优我们先看看通过内核的哪些参数能够提高Ingress的性能。保证在高并发环境下,发挥Ingress的最大性能。调大全连接队列的大小TCP全连接队列的最大值取决于som......
  • CF1809G prediction - dp - 组合数学 -
    题目链接:https://codeforces.com/contest/1809/problem/G题解:一道很强的dp首先翻译条件:predictable是什么意思?发现就是对每一个下标,前缀max和下一个位置至少差一个......
  • nginx配置vue打包npm build的静态页面
    nginx配置vue项目server{listen8081;server_name10.8.8.8;indexindex.html;root/home/www/crm/vue/dist;#SSL-STARTSSL相关配置,请勿删......
  • 低压无感BLDC方波控制,全部源码,方便调试移植
    低压无感BLDC方波控制,全部源码,方便调试移植1.通用性极高,图片中的电机,一套参数即可启动。2.ADC方案3.电转速最高12w4.电感法和普通三段式5.按键启动和调速6.开环,速......
  • 一篇搞定Nginx功能
    from:https://mp.weixin.qq.com/s/yF5h7dslESaa3Gt5rE6IbQ 引言一、性能怪兽-Nginx概念深入浅出二、Nginx环境搭建三、Nginx反向代理-负载均衡四、Nginx动静分离......
  • 一文剖析:LVS/Nginx/HAProxy原理及应用场景
    负载均衡已经发展成为网络架构中的基础核心组件,消除了服务器单点故障,可以进行请求流量分流,提升冗余,保证服务器的稳定性。在开源的软件负载均衡中,应用最为广泛的有LVS、Nginx......
  • 第九天(nginx-第三篇--------nginx的相关总结)
    1.1、Nginx​Nginx(enginex)是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点......