栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Nginx请求转发到后端服务器/K8S/PaaS

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nginx请求转发到后端服务器/K8S/PaaS

Nginx请求转发到后端服务器/K8S/PaaS
  • Nginx安装及配置
    • Nginx安装
  • 配置Nginx转发到后端服务器/K8S/PaaS

Nginx安装及配置 Nginx安装
  1. https://nginx.org/en/download.html下载nginx
   解压:tar –xzf nginx-1.10.3.tar.gz && cd nginx-1.10.3
   配置:./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
   编译安装 sudo make && sudo make install
   启动:/usr/local/nginx/sbin/nginx
   查看进程:ps –aux | grep nginx
   验证 curl http://127.0.0.1/
  1. 如果安装时提示缺少compiler cc,需要安装gcc,可以从网址http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/下载以下包:
mpfr-3.1.1-4.el7.x86_64.rpm
libmpc-1.0.1-3.el7.x86_64.rpm
kernel-headers-3.10.0-123.el7.x86_64.rpm
glibc-headers-2.17-55.el7.x86_64.rpm
glibc-devel-2.17-55.el7.x86_64.rpm
cpp-4.8.2-16.el7.x86_64.rpm
gcc-4.8.2-16.el7.x86_64.rpm
  1. 然后安装:rpm -Uvh *.rpm --nodeps --force
  2. 如果安装时提示./configure: error: the HTTP rewrite module requires the PCRE library.
  3. 安装openssl即可:yum -y install openssl openssl-devel
  4. 如果提示需要PCRE包:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
  1. 需要进行安装:yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
配置Nginx转发到后端服务器/K8S/PaaS
worker_processes  1;
user root; # 如果nginx没有权限写入到临时文件目录下可能会抛出异常,需要设置为root用户,或在目录下给nginx授权。

events {
    worker_connections  1024;
}

http {

    include       mime.types;

    default_type  application/octet-stream;
    
    # 以下几个字段为文件相关的,如果遇到413 Request Entity Too Large或500时需要配置
    # nginx的异常可查看error.log进行定位
    client_max_body_size 1000m; # 上传文件的最大值
    client_body_buffer_size 100m; # 请求缓存区的大小
    client_body_temp_path /tmp; # 临时文件存放目录,只有当上传的请求体超出缓存区大小时,才会写到临时文件中。

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  localhost;

        location / {
            # nginx的转发配置
            proxy_pass {PaaS应用的域名};

            proxy_redirect off;

        }
    }
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/499120.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号