nginx配置文件一

简介: 下面的nginx配置文件nginx.conf配置的不是轮询策略做tomcat集群负载,而是定向请求,也算做了个简单的请求分发负载。比如app单独请求一个服务器(tomcat),web单独请求一个服务器(tomcat),管理后台单独请求一个服务器(tomcat),后期轮询配置也会进行整理

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;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
          root    .../resources/xxx_xiangmu;
          index  xxx_xiangmu_index.html xxx_xiangmu_index.htm;
    }

    location /xxx_pre/{
        root   /usr/local/java_root/resources;
           #/usr/local/java_root/resources下面放xxx_pre文件夹
               }
      location /app/ {
     proxy_pass http://127.0.0.1:8081;
      }

     location /web/ {
     proxy_pass http://127.0.0.1:8082;
       }

       location /manage/ {
     proxy_pass http://127.0.0.1:8083;
       }

     location /static/ {
       root   .../webapps/ROOT;
       #(根据自己实际目录配置,这里tomcat/webapps/ROOT下面有static文件夹,
       #这里算是偷懒了,最好把静态资源单独放到一个resources文件夹)
      }



    #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;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}


# HTTPS server
#
server {
    listen       443;
    server_name  www.xxx.com;
    ssl on;
    ssl_certificate      /usr/local/nginx/cert/xxxxxxxxxxxxx.pem;
    ssl_certificate_key  /usr/local/nginx/cert/xxxxxxxxxxxxx.key;

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location / {
        root   html;
        index  index.html index.htm;
    }

     }

}

相关文章
|
10月前
|
存储 Ubuntu 应用服务中间件
【Nginx】centos和Ubuntu操作系统下载Nginx配置文件并启动Nginx服务详解
【Nginx】centos和Ubuntu操作系统下载Nginx配置文件并启动Nginx服务详解
150 1
|
5月前
|
缓存 负载均衡 应用服务中间件
nginx的配置文件详解
本文详细解释了nginx配置文件中的关键指令和区块,如http、server、location、upstream、events等,并通过一个示例配置文件展示了如何设置HTTP服务器、gzip压缩、反向代理、URL重写、错误页面和负载均衡等,强调了配置的灵活性和实际应用。
163 4
|
1月前
|
网络协议 前端开发 应用服务中间件
nginxconf.sh 自动生成 nginx tcp 转发配置文件 conf
该脚本由 eisc.cn 开发,用于自动生成 Nginx 代理配置。它根据预设的域名、IP 和端口信息,为多个项目(如 www、work、sou 等)创建对应的 Nginx 配置文件,设置前端转发、端口对端口及后端转发规则,并生成日志和 301 跳转配置。支持自动创建 CGI 解析目录,确保各项目能够正确访问。运行时需具备 root 权限或使用 sudo。
73 9
|
10月前
|
负载均衡 应用服务中间件 API
Nginx配置文件详解Nginx负载均衡Nginx静态配置Nginx反向代理
Nginx配置文件详解Nginx负载均衡Nginx静态配置Nginx反向代理
219 4
|
5月前
|
负载均衡 应用服务中间件 Linux
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
这篇博客文章详细介绍了Nginx的下载、安装、配置以及使用,包括正向代理、反向代理、负载均衡、动静分离等高级功能,并通过具体实例讲解了如何进行配置。
251 4
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
|
9月前
|
缓存 负载均衡 应用服务中间件
深入解析Nginx配置文件
Nginx是一个高性能HTTP服务器和反向代理,其配置文件`nginx.conf`包含全局、事件、HTTP、Server和Location块。全局块设置如用户和工作进程数,事件块设定连接数,HTTP块涉及MIME类型、日志和包含其他配置。Server块定义虚拟主机,Location块处理URI匹配。Nginx常用于反向代理和负载均衡,如`proxy_pass`指令转发请求至后端服务器组。理解这些配置有助于服务器优化和测试。
|
5月前
|
缓存 负载均衡 算法
nginx学习:配置文件详解,负载均衡三种算法学习,上接nginx实操篇
Nginx 是一款高性能的 HTTP 和反向代理服务器,也是一个通用的 TCP/UDP 代理服务器,以及一个邮件代理服务器和通用的 HTTP 缓存服务器。
286 0
nginx学习:配置文件详解,负载均衡三种算法学习,上接nginx实操篇
|
5月前
|
域名解析 网络协议 应用服务中间件
nginx server_name配置文件覆盖不生效
nginx server_name配置文件覆盖不生效
|
5月前
|
应用服务中间件 nginx
nginx 配置文件
nginx 配置文件
|
7月前
|
运维 应用服务中间件 网络安全
运维系列.Nginx配置文件结构功能总结
运维系列.Nginx配置文件结构功能总结
124 0
运维系列.Nginx配置文件结构功能总结