yum install nginx
yum install nginx-mod-stream -y
stream {
server {
listen 8666;
proxy_connect_timeout 360s;
proxy_timeout 360s;
proxy_pass xxx.xxx.xxx.xxx:8666;
}
}
# 运行
./opt/nginx/sbin/nginx
# 重载配置文件
./opt/nginx/sbin/nginx -s reload
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
PCRE (Perl Compatible Regular Expressions) 是一个用于处理正则表达式的库,它是一个C语言的库,可以在多种编程语言中使用。PCRE库提供了一套API来编译和执行正则表达式,并提供了一组函数来匹配、查找和替换文本中符合正则表达式的模式。PCRE库与Perl的正则表达式语法兼容,因此可以直接使用Perl的正则表达式语法。
如果我们在nginx.conf配置文件中使用了正则表达式,那么在编译Nginx时必须将PCRE库编译进Nginx。这是因为Nginx的HTTP模块需要依赖PCRE库来解析正则表达式。
cd /usr/local/src/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar zxvf pcre-8.35.tar.gz
./configure
make && make install
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.25.3.tar.gz
tar zxvf nginx-1.25.3.tar.gz
cd nginx-1.25.3
./configure --prefix=/opt/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-pcre=/usr/local/src/pcre-8.35 --with-stream
# 编译
make
# 安装
make install
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
#pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
# include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
include mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /opt/nginx/conf/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /opt/nginx/conf/default.d/*.conf;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
include /opt/nginx/conf/vhosts/*.conf;
}
stream {
server {
listen 8666;
proxy_connect_timeout 360s;
proxy_timeout 360s;
proxy_pass locktcp.cosinwx.com:8666;
}
}
# 运行
./opt/nginx/sbin/nginx
# 重载配置文件
./opt/nginx/sbin/nginx -s reload