安装需要依赖包
yum -y install bash-completion.noarch gcc gcc-c++ cmake openssl-devel pcre-devel
编译参数
tcp代理参数(–with-stream --with-stream_ssl_module)
./configure --prefix=/opt/nginx --with-pcre --user=daemon --group=daemon --with-http_stub_status_module --without-http_gzip_module --with-http_ssl_module --with-http_v2_module --with-http_gunzip_module --with-stream --with-stream_ssl_module
make -j4 && make install
配置
user daemon;
worker_processes auto;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
#虚拟主机
include /usr/local/nginx/vhost/*.conf;
server {
listen 443 http2 ssl;
server_name jjb.com;
ssl_certificate /usr/local/nginx/key/fullchain.pem;
ssl_certificate_key /usr/local/nginx/key/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
index index.jsp index.do index.html index.htm;
proxy_pass https://172.20.0.66:8086;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
虚拟机主机配置
[root@ecs-8da7 ~]# cat /usr/local/nginx/vhost/admin.conf
server{
listen 80;
server_name admin.JBJB.COM;
location / {
proxy_pass http://172.20.0.77:8980;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header Host $http_host;
}
location /log {
alias /data/log;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
}
}
TCP代理配置
events {
worker_connections 1024;
}
stream {
upstream bitbucket-mysql {
server 172.20.0.11:3306;
}
server {
#listen 33306;
listen 33306 so_keepalive=on;
proxy_pass bitbucket-mysql;
tcp_nodelay on;
}
}