centos 安装nginx

2023-05-16

1.安装源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2.安装nginx

yum -y install nginx

3.配置nginx


#user  nobody;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;  
    keepalive_timeout  3600;

    server {
	charset utf-8;
        listen       80;
        server_name 	test.rendu.cn;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
	client_max_body_size 100m;
		
        location / {
            	root /data/rendu-web;#react/vue项目的打包后的distroot
		try_files $uri $uri/ /index.html;
		#禁止缓存,每次都从服务器请求
		add_header Cache-Control no-store;
	}
	location /file/download/ {
		proxy_pass http://192.168.1.151:3180/;
		proxy_buffering off;
	}
	location /api/ {
		proxy_http_version 1.1;
		proxy_read_timeout 3600s;
		proxy_send_timeout 3600s;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://127.0.0.1:9538/api/;
	}

    }

}

4.启动nginx

systemctl start nginx

5.配置开机启动

systemctl enable nginx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

centos 安装nginx 的相关文章

随机推荐