監聽80端口 轉發多端口
- 以域名
www.xxx.com
為例子
監聽80
端口 將 test1.xxx.com
轉發到8080
端口
監聽80
端口 將 test2.xxx.com
轉發到8070
端口
監聽80
端口 將 www.xxx.com
轉發到本地靜態html路徑
user root;
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 將 test1.xxx.com 轉發到8080端口
upstream test1.xxx.com {
server 127.0.0.1:8080;
}
#監聽80端口 將 test1.xxx.com 轉發到本地8080端口
server {
listen 80;
server_name test1.xxx.com;
client_max_body_size 1000M;
location / {
proxy_pass http://test1.xxx.com;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
#監聽80端口 將 test2.xxx.com 轉發到8070端口
server {
listen 80;
server_name test2.xxx.com;
client_max_body_size 1000M;
location /{
proxy_pass http://ip: 8070;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# 監聽80端口 將 www.xxx.com 轉發到本地靜態html
server {
listen 80;
server_name www.xxx.com;
client_max_body_size 1000M;
location /{
alias /usr/local/web/html/officialWebsite/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# 監聽8888端口 這是FastDFS 轉發到ngx_fastdfs_module
server {
listen 8888;
server_name ip;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
切換源碼包
cd /usr/local/src/nginx-1.15.4
添加模塊
./configure --with-http_stub_status_module --with-http_ssl_module --add-module=/usr/local/src/fastdfs-nginx-module/src/
配置完成后,運行命令
make
cp
cp ./objs/nginx /usr/local/nginx/sbin/
查看安裝模塊
/usr/local/nginx/sbin/nginx -V
運行
./sbin/nginx -t