软件包如下:
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
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:后台的代理nginx部署方法 - Python技术站