首页 > 后台的代理nginx部署方法

后台的代理nginx部署方法

软件包如下:

nginx-1.10.0.tar.gz

nginx-http-concat-master.zip

ngx_cache_purge-2.3.tar.gz

openssl-1.0.2h.tar.gz

pcre-8.39.tar.gz

zlib-1.2.8.tar.gz



ngin部署方法:

上面的安装包都存放在/apps/svr/soft目录下:

cd /apps/svr/soft

tar -zxf nginx-1.10.0.tar.gz 

tar -zxf pcre-8.38.tar.gz

tar -zxf zlib-1.2.8.tar.gz

tar -zxf openssl-1.0.2h.tar.gz

useradd apps

cd nginx-1.10.0

./configure --prefix=/apps/svr/nginx

--user=apps

--group=apps

--with-pcre=/apps/svr/soft/pcre-8.39

--with-zlib=/apps/svr/soft/zlib-1.2.8

--with-openssl=/apps/svr/soft/openssl-1.0.2h

--with-http_ssl_module

--with-http_stub_status_module

--without-mail_pop3_module

--without-mail_imap_module

--without-mail_smtp_module

--add-module=/apps/svr/soft/ngx_cache_purge-2.3/

--add-module=/apps/svr/soft/nginx-http-concat-master/

make

make install

cd /apss/svr/nginx/conf

cat nginx.conf

user apps apps;

worker_processes 12;

#worker_cpu_affinity 000000000000000000000001 000000000000000000000010 000000000000000000000100 000000000000000000001000 000000000000000000010000 000000000000000000100000 000000000000000001

000000 000000000000000010000000 000000000000000100000000 000000000000001000000000 000000000000010000000000 000000000000100000000000;

error_log /apps/svr/nginx/logs/nginx_error.log crit;

pid /apps/svr/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 65535;

events

{

use epoll;

worker_connections 65535;

}

http

{

include mime.types;

#geoip_city /usr/local/nginx/conf/GeoLiteCity.dat;

#include geo.conf;

default_type application/octet-stream;

#charset gb2312;

server_names_hash_bucket_size 128;

client_header_buffer_size 4k;

large_client_header_buffers 4 32k;

client_max_body_size 80m;

sendfile on;

tcp_nopush on;

client_body_timeout 5;

client_header_timeout 5;

keepalive_timeout 5;

send_timeout 5;

open_file_cache max=65535 inactive=20s;

open_file_cache_valid 30s;

open_file_cache_min_uses 1;

tcp_nodelay on;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 128k;

client_body_buffer_size 512k;

proxy_connect_timeout 5;

proxy_read_timeout 60;

proxy_send_timeout 5;

proxy_buffer_size 16k;

proxy_buffers 4 64k;

proxy_busy_buffers_size 128k;

proxy_temp_file_write_size 128k;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types text/plain application/x-javascript text/css application/xml;

gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m;

proxy_temp_path /dev/shm/temp;

proxy_cache_path /dev/shm/cache levels=2:2:2 keys_zone=cache_go:200m inactive=5d max_size=7g;

log_format log_access '$remote_addr - $remote_user [$time_local] "$request" "$request_time" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" $http_x_forwarded_for $host $hostname';

upstream tomcat-m {

               server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=2s;

               #server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=2s down;

}

upstream tomcat-kepler {

                server 127.0.0.1:8081 weight=1 max_fails=2 fail_timeout=2s;

}

upstream tomcat-customer {

                server 127.0.0.1:8082 weight=1 max_fails=2 fail_timeout=2s;

}

upstream tomcat-order {

                server 127.0.0.1:7500 weight=1 max_fails=2 fail_timeout=2s;

}

upstream tomcat-pms {

                server 127.0.0.1:8083 weight=1 max_fails=2 fail_timeout=2s;

}

upstream tomcat-t {

               #server 127.0.0.1:8086 weight=1 max_fails=2 fail_timeout=30s;

               server 127.0.0.1:8086 weight=1 max_fails=2 fail_timeout=30s down;

}

upstream tomcat-df {

               server 127.0.0.1:8087 weight=1 max_fails=2 fail_timeout=30s;

               #server 127.0.0.1:8087 weight=1 max_fails=2 fail_timeout=30s down;

}

# Monit Nginx

#include /apps/conf/nginx/vhosts/m.daxmall.com;

#include /apps/conf/nginx/vhosts/daxmall.com;

include /apps/svr/nginx/conf/vhosts/*.conf;

server {

listen *:80 default_server;

server_name _;

location /ngx_status 

{

stub_status on;

access_log off;

#allow 127.0.0.1;

#deny all;

}

}

}

mkdir /apps/svr/nginx/conf/vhosts -p

mkdir /apps/svr/nginx/logs -p



域名配置文件1:

vi m.daxmall.com.conf

server {

listen 80;

server_name m.daxmall.com;

error_page 500 502 503 504 /50x.html;

access_log /apps/svr/nginx/logs/m.daxmall.access.log log_access;

location ~ .*.txt$ {

root /apps/dat/web/8080_weixin;

}

location / {

proxy_pass http://tomcat-m/;

proxy_set_header Host $http_host;

proxy_set_header Cookie $http_cookie;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 300m;

}

}





域名配置文件2:

vi daxmall.com.conf

server {

listen 80;

server_name daxmall.com www.daxmall.com;

#server_name mallbeta2.daxmall.com www.daxmall.com;

error_page 500 502 503 504 /50x.html;

access_log /apps/svr/nginx/logs/m.daxmall.access.log log_access;

location / {

proxy_pass http://tomcat-df/;

proxy_set_header Host $http_host;

proxy_set_header Cookie $http_cookie;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

client_max_body_size 300m;

}

location /timer/ {

proxy_pass http://tomcat-t/;

proxy_set_header Host $host:$server_port;

}

location /task/ {

proxy_pass http://tomcat-t/task/;

proxy_set_header Host $host:$server_port;

proxy_redirect / /task/;

}

}

mkdir -p /apps/dat/web/8080_weixin

echo "uXrXy6khdgJVd96l">MP_verify_uXrXy6khdgJVd96l.txt

启动nginx服务:

cd /apps/svr/nginx/sbin/

chown root.apps nginx

chmod 750 nginx

chmod u+s nginx

/apps/svr/nginx/sbin/nginx

转载于:https://www.cnblogs.com/hyming011/p/8252650.html

更多相关:

  •   最近用Yii2.0框架做了个小项目,虽然项目本身业务逻辑不复杂,但是由于本身业务逻辑的特殊性,在上午9点到12点之间系统访问量会突然上升(浏览量和用户上传文件量)。导致系统单纯的部署在Apache下,支撑不了这么多的并发数;单独部署Nginx又由于用户频繁的提交数据,出现大量的502错误。然后又由于各方面的原因,就想通过Nginx...

  • 知识点:   server的语法:   upstream语法:     upstream中192.168.100.1不是ip只是个标识,只要和下面的proxy_pass 对应即可。   基于IP的虚拟主机:     listen和server_name中多加上端口也没问题     listen可以监听在虚拟ip上面   代码: ups...

  • 编译Apache时要进行的设置./configure --enable-mods-shared="all proxy"1>修改 httpd.conf 文件中:LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_p...

  • 一般情况下,从App Store安装的应用程序,如果应用删除,那么launchpad里对应的图标会一起删除了。 而对于不是通过App Store安装的应用程序,删除应用程序,Launchpad中很可能仍然留有相关程序图标。不能忍!是要逼死强迫症嘛? DaDa, 我们用直接操作数据库的方法直接 delete 掉讨厌的残留。 我们以删除“...

  • EBS几个默认的登录帐户和密码:   sysadmin/sysadmin mfg/welcome operations/welcome services/welcome mrc/welcome hrms/welocme projmfg/welcome   摘自http://tian-pan.com/?p=62   EBS数据库层登录账...

  • curl有curlopt_connecttimeout可设,fsockopen有$timeout可设,而file_get_contents和fopen在打开url时,都不可设置响应时间timeout。如果url长时间没有响应,file_get_contents 会跳过短时间内没有响应的,而fopen会一直停留着等待,那么您的服务器就...