CentOS 安装、配置Nginx反向代理

安装:

yum install epel-release

yum install nginx

配置:

/etc/nginx/nginx.conf

server {
    listen        80;//监听端口号
    server_name   example.com *.example.com;
    location / {
            proxy_pass         http://localhost:5000;//转发到
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection keep-alive;
            proxy_set_header   Host $http_host;
            proxy_cache_bypass $http_upgrade;
    }
}

启动服务:

systemctl start nginx

或者源码安装:

http://www.nginx.org/

编译安装:

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

./configure

make

make install

配置文件:

/usr/local/nginx/conf/nginx.conf

启动:

/usr/local/nginx/sbin/nginx

猜你喜欢

转载自www.cnblogs.com/wangjq19920210/p/10815515.html