代码编织梦想

1、下载nginx,http://nginx.org/en/download.html

2、解压后双击nginx.exe文件或通过cmd进入解压目录执行nginx.exe启动服务,关闭服务需要通过cmd进入解压目录执行nginx -s stop,启动后访问localhost可以进入欢迎页。

3、复制3个tomcat,分别命名tomcat_1、tomcat_2、tomgcat_3,将各自端口进行修改为8080、8081、8082。

4、在nginx目录的conf中修改nginx.conf文件。

#user  nobody;
worker_processes  4;    # 工作进程的个数,一般与计算机的cpu核数一致

#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;    # 开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为on,如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;    # 长连接超时时间,单位是秒

    #gzip  on;    # 启用Gizp压缩

    #服务器的集群
    upstream zsq {  # 服务器集群名字
        server    127.0.0.1:8080  weight=1;    # 服务器配置   weight是权重的意思,权重越大,分配的概率越大。
        server    127.0.0.1:8081  weight=2;
		server    127.0.0.1:8082  weight=3;
    }

    # 当前的Nginx的配置
    server {
        listen       80;    # 监听80端口,可以改成其他端口
        server_name  localhost;    # 当前服务的域名

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            # root   html;
            # index  index.html index.htm;
            proxy_pass http://zsq;# 访问地址
            proxy_redirect default;
        }

        #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 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.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;
    #    }
    #}

}

4、分别启动三个tomcat,最后启动nginx,访问http://localhost,会随机进入到8080/8081/8082中。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接: https://blog.csdn.net/qq_19686623/article/details/111072629

Kubernetes-DashBoard安装使用-爱代码爱编程

之前在kubernetes中完成的所有操作都是通过命令行工具kubectl完成的。其实,为了提供更丰富的用户体验,kubernetes还开发了一个基于web的用户界面(Dashboard)。用户可以使用Dashboard部署容器化的应用,还可以监控应用的状态,执行故障排查以及管理kubernetes中各种资源。 #下载 wget https://raw.

一文让你深刻理解异步请求池-DNS解析与实现-爱代码爱编程

一、DNS概念简述 DNS:Domain Name Service 域名解析服务,工作在应用层,是互联网的一项服务。它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网。DNS监听在TCP和UDP端口53。FQDN:全称域名,如 www.example.com www是主机名example.com是域名实现名称到IP解析的有三种

Gavin小黑屋——Docker 学习笔记-爱代码爱编程

docker命令 目录 docker命令 镜像命令 docker search搜索镜像 docker pull下载镜像 rim --remove 删除镜像 容器命令 docker run [可选参数] image #退出容器 列出所有运行的容器 删除容器  启动和停止容器的操作 常用其他命令 查看日志 部署Nginx 官方使

Tengine简单配置-爱代码爱编程

Tengine简单配置 安装 tengine打开虚拟机关闭nginx制作启动服务脚本修改可执行权限启动服务Nginx配置解析定义Nginx运行的用户和用户组进程数全局错误日志进程文件打开的最多文件描述符event单个进程最大连接数打开文件句柄数量限制httpsendfilegzipserver虚拟主机locationlocation配置规则IP访问

Kubernetes-pod控制器-ReplicaSet(RS)-爱代码爱编程

Deployment(Deploy)企业常常使用 为了更好的解决服务编排的问题,kubernetes在V1.2版本开始,引入了Deployment控制器。值得一提的是,这种控制器并不直接管理pod,而是通过管理ReplicaSet来间接管理Pod,即: Deployment管理ReplicaSet,ReplicaSet管理Pod。所以Deployment

Kubernetes-pod控制器-DaemonSet(DS)-爱代码爱编程

DaemonSet(DS) DaemonSet类型的控制器可以保证集群中的每一台(或指定)节点上都运行一个副本,一般适用于日志收集、节点监控等场景。也就是说,如果一个pod提供的功能是节点级别的(每个节点都需要且只需要一个),那么这类Pod就适合使用DaemonSet类型的控制器创建。 DameonSet控制器的特点: 每当向集群中添加一个节点时,指