nginx设置域名转发到指定端口

时间:2024-01-26 10:55:08

1、修改nginx.conf文件,将worker_processes  1 修改为  worker_processes  auto

 

 

2、创建端口代理配置文件(域名地址如:xx.baidu.com , 转发地址如:127.0.0.1:8080)

upstream 域名地址 {
                server 转发地址 weight=1 max_fails=5 fail_timeout=200s;
}
server
        {
        listen 80;
        server_name 域名地址;
location /
        {
        proxy_pass http://域名地址;
}
    
       access_log /etc/nginx/logs/access.log ;
       error_log /etc/nginx/logs/error.log error;
}