【Nginx用法】nginx配置内容

本文涉及的产品
全局流量管理 GTM,标准版 1个月
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
云解析 DNS,旗舰版 1个月
简介: 【Nginx用法】nginx配置内容

记录一下,项目当中使用的nginx配置(本地启动)

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

   worker_connections  1024;

}

http {

   include       mime.types;

   default_type  application/octet-stream;

   #access_log  logs/access.log  main;

   sendfile        on;

   #tcp_nopush     on;

   #keepalive_timeout  0;

   keepalive_timeout  65;

   #gzip  on;

   server {

       listen       9000;

       

       server_name      www.unisiot.com;

       #server_name      ~^((?<subdomain>.*)\.)?unisiot\.com$;

       if ($subdomain = ""){

          set $subdomain "www";

       }

   

       index        index.html index.htm;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;

       

       ssi on;

       ssi_silent_errors on;

       #ssi_types text/shtml;

       expires 30d;

       

       location / {

       

           root   F:/mainsite_root/mainsite/$dns;

           index   index.html index.htm;

         

           if ($host ~ (^\S*?(?=\.\S*))){

               set $dns $1;

           }

           #alias F:/mainsite_root/mainsite/$dns;

           #index index.html;

         

           #判断终端

           if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry|iPad)') {

              set $mobile_request '1';

              #如果访问UA为移动终端类型则判断为mobile_request=1

           }

           if ($http_cookie ~ 'mobile_request=full') {

              set $mobile_request '';

           }

           if ($mobile_request = '') {

              #proxy_pass http://139.196.188.213;

              #判断mobile_request等于空则为PC终端

              root   F:/mainsite_root/mainsite/$dns/web;

           }

       

           #break;

           

           if ($uri ~* '(lobby|bedroom|livingroom|lavatory|kitchen|videoroom)') {

               root   F:/mainsite_root/mainsite/$dns;

           }

       }

       

       location /commonHtml {

           alias   F:/mainsite_root/common/;    

       }

       

       location /$subdomain {

           alias   F:/mainsite_root/mainsite/$subdomain;    

       }

       

       location ~ ^/(BJUI|ckeditor4.8|common|images|js|nice-validator|www|static)/ {

           root   F:/mainsite_root/static;

           autoindex on;

           access_log  off;

           expires     30d;          

       }

       

       location ~ ^/(upload)/ {

           root   F:/mainsite_root/;

           autoindex on;

           access_log  off;

           expires     30d;          

       }

       

       #error_page  404              /404.html;

       # redirect server error pages to the static page /50x.html

       #

       error_page   500 502 503 504  /50x.html;

       location = /50x.html {

           root   html;

       }

   }

}

 

 

 

完结!


目录
打赏
0
0
0
0
17
分享
相关文章
Nginx中配置HTTP2协议的方法
Nginx中配置HTTP2协议的方法
247 7
Nginx的location配置详解
【10月更文挑战第16天】Nginx的location配置详解
Nginx常用基本配置总结:从入门到实战的全方位指南
Nginx常用基本配置总结:从入门到实战的全方位指南
540 0
Jetson 环境安装(四):jetson nano配置ffmpeg和nginx(亲测)之编译错误汇总
这篇文章是关于在Jetson Nano上配置FFmpeg和Nginx时遇到的编译错误及其解决方案的汇总。
180 4
nginx配置证书和私钥进行SSL通信验证
nginx配置证书和私钥进行SSL通信验证
69 4
配置Nginx反向代理时如何指定后端服务器的权重?
配置Nginx反向代理时如何指定后端服务器的权重?
240 61
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
如何测试Nginx反向代理实现SSL加密访问的配置是否正确?
254 60
配置Nginx反向代理实现SSL加密访问的步骤是什么?
我们可以成功地配置 Nginx 反向代理实现 SSL 加密访问,为用户提供更安全、可靠的网络服务。同时,在实际应用中,还需要根据具体情况进行进一步的优化和调整,以满足不同的需求。SSL 加密是网络安全的重要保障,合理配置和维护是确保系统安全稳定运行的关键。
331 60
nginx反向代理bucket目录配置
该配置实现通过Nginx代理访问阿里云OSS存储桶中的图片资源。当用户访问代理域名下的图片URL(如 `http://代理域名/123.png`)时,Nginx会将请求转发到指定的OSS存储桶地址,并重写路径为 `/prod/files/2024/12/12/123.png`。
116 5
如何配置Nginx反向代理以实现负载均衡?
如何配置Nginx反向代理以实现负载均衡?