您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Linux下nginx相关配置

2024/12/27 3:09:46发布13次查看
公司服务器项目使用nginx做转发及负载均衡,在这期间遇到一些,尤其是404问题,下面就说说我的nginx配置,以及我对404的解决。
我这里用了两个配置文件
1、nginx.conf配置文件
#user nobody;worker_processes 1;#pid logs/nginx.pid;error_log /var/log/nginx/error.log;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #access_log logs/access.log main; port_in_redirect off ; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root html; #} include /usr/local/nginx/conf/conf.d/*.conf; client_max_body_size 32m;client_body_buffer_size 1024k;}
2、在conf.d文件夹下新建了一个文件oa.conf #upstream t { # server 192.168.7.176:8888; #server 127.0.0.1:8888; #}server{ listen 80; server_name t.test.minisocials.com; location / { real_ip_header x-real-ip;# proxy_pass http://t; proxy_pass http://192.168.7.176:8888; access_log /usr/local/nginx/t.log; }}
注:upstream用于做负载均衡,由于我的是测试服务器就不需要做负载均衡,故内容注释3、现在说说404的问题
当初公司测试服务器nginx不知道是谁安装的,nginx.conf有两个配置文件,一个在/etc/nginx/nginx.conf,另一个在/usr/local/nginx/conf/nginx.conf,然后我修改的是/usr路径下的配置文件,导致修改过的内容一直报错404,后来通过nginx -t命令使配置文件生效,看到了生效的配置文件路径是/etc下的配置文件,才发现原来我之前改的位置不对,然后将我改的配置文件替换了/etc路径下的配置文件,就ok了,没有出现404了,挺搓的我,哈哈。。。
4、第一次接触nginx,参考的资料:nginx中文文档  nginx官网
以上就介绍了linux下nginx相关配置,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product