Nginx请求转发到后端服务器/K8S/PaaS Nginx请求转发到后端服务器/K8S/PaaSNginx安装及配置Nginx安装配置Nginx转发到后端服务器/K8S/PaaSNginx安装及配置Nginx安装https://nginx.org/en/download.html下载nginx解压:tar–xzfnginx-1.10.3.tar.gz&&cdnginx-1.10.3配置:./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module编译安装sudomake&&sudomakeinstall启动:/usr/local/nginx/sbin/nginx查看进程:ps–aux|grepnginx验证curlhttp://127.0.0.1/如果安装时提示缺少compilercc,需要安装gcc,可以从网址http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/下载以下包:mpfr-3.1.1-4.el7.x86_64.rpmlibmpc-1.0.1-3.el7.x86_64.rpmkernel-headers-3.10.0-123.el7.x86_64.rpmglibc-headers-2.17-55.el7.x86_64.rpmglibc-devel-2.17-55.el7.x86_64.rpmcpp-4.8.2-16.el7.x86_64.rpmgcc-4.8.2-16.el7.x86_64.rpm然后安装:rpm-Uvh*.rpm--nodeps--force如果安装时提示./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.安装openssl即可:yum-yinstallopensslopenssl-devel如果提示需要PCRE包:./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.Youcaneitherdisablethemodulebyusing--without-http_rewrite_moduleoption,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrarystaticallyfromthesourcewithnginxbyusing--with-pcre=
option.需要进行安装:yum-yinstallzlibzlib-developensslopenssl--develpcrepcre-devel配置Nginx转发到后端服务器/K8S/PaaSworker_processes1;userroot;#如果nginx没有权限写入到临时文件目录下可能会抛出异常,需要设置为root用户,或在目录下给nginx授权。events{worker_connections1024;}http{includemime.types;default_typeapplication/octet-stream;#以下几个字段为文件相关的,如果遇到413RequestEntityTooLarge或500时需要配置#nginx的异常可查看error.log进行定位client_max_body_size1000m;#上传文件的最大值client_body_buffer_size100m;#请求缓存区的大小client_body_temp_path/tmp;#临时文件存放目录,只有当上传的请求体超出缓存区大小时,才会写到临时文件中。sendfileon;keepalive_timeout65;server{listen80;server_namelocalhost;location/{#nginx的转发配置proxy_pass{PaaS应用的域名};proxy_redirectoff;}}} -全文完-