centos-1 nginx

时间:2024-10-28 18:36:32

常用命令

su #切换用户
mkdir flodr #创建目录
rm -r flodr #删除文件/目录,有提示
rm -rf flodr #删除文件/目录,无提示
pwd #查看当前路径

 防火墙设置

https://www.cnblogs.com/moxiaoan/p/5683743.html

 安装 Nginx

yum install nginx

修改nginx.conf 文件

vim /etc/nginx/nginx.conf
/etc/nginx/:是nginx的安装目录

默认日志文件
/var/log/nginx/access.log
NGINX 403错误是因为没有权限(在/etc/nginx/nginx.conf)第一名加上句代码
user  root;

重启Nginx
service nginx restart

反向代理的配置。

server {
listen 80; server_name shop2.eey9r.cn; location /{
proxy_pass http://127.0.0.1:8082; #Proxy Settings
proxy_redirect off;
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_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
} error_log /root/nginx/logs/error_shop2.log error; access_log /root/nginx/logs/access_shop2.log main; }

server {
listen 80;
server_name task.eey9r.cn;


location /xxljob{
proxy_pass http://121.196.215.32:8080;
}


location /{
proxy_pass http://121.196.215.32:8080/xxljob/;
}
}