win7下的nginx小demo

一直大概知道nginx怎么玩,但是不看文档又蒙蔽.在这记录一下,以后好查看

  • 下载tomcat,改index.jsp

http://tomcat.apache.org/download-80.cgi

tomcat9已经出来了,但是自己用了一次,闪退,换tomcat8,开启成功.(tomcat9这个原因有时间在琢磨)

修改tomcat的index.jsp

然后在index.jsp加点标记

  <div id="asf-box">
                <h1>
                    tomcat3的session是:
                    <%=request.getSession().getId()%>
                </h1>
                <h1>${pageContext.servletContext.serverInfo}</h1>
            </div>

 

然后依次完成三个tomcat

  • 定义nginx

官网下载

http://nginx.org/en/download.html

解压目录,修改nginx.conf

#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;
    
    
    
    #设置反向代理的服务器列表
    upstream test_ip{
        server localhost:8080 weight=1;
        server localhost:8081 weight=1;
        server localhost:8082 weight=1;
        #配置轮询
        #ip_hash
    
    }
    

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        
        
        #配置方向代理的路径
        location / {
            root   html;
            proxy_pass http://test_ip;
            index  index.html index.htm;
        }

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

}

标红的字体的upstream的定义表示了访问列表

在location中定义的proxy_pass

  • 开启nginx,tomcat

点击nginx.exe一闪而过

点击三个tomcat的startup.bat

 

最后,输入localhost在浏览器,访问

 

 

最后再次输入local就会发现session值改变了,说明nginx反向代理成了

 

最后

nginx -s reload  :修改配置后重新加载生效

nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:
nginx -s stop  :快速停止nginx
         quit  :完整有序的停止nginx

 

转载于:https://www.cnblogs.com/summer-fate/p/7507791.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428753.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

understand的安装

1.win7 64位下安装 1&#xff09;下载Understand.4.0.908.x64.rar。 2&#xff09;解压之&#xff0c;直接运行里面的Understand-4.0.908-Windows-64bit.exe。 3&#xff09;选择如下 之后&#xff0c;点击“Add Eval or SDL (RegCode)”&#xff0c;如下图&#xff1a; 4&…

C. Number of Pairs

C. Number of Pairs You are given an array a of n integers. Find the number of pairs (i,j) (1≤i<j≤n) where the sum of aiaj is greater than or equal to l and less than or equal to r (that is, l≤aiaj≤r). For example, if n3, a[5,1,2], l4 and r7, then t…

A. Arithmetic Array Codeforces Round #726 (Div. 2)

A. Arithmetic Array An array b of length k is called good if its arithmetic mean is equal to 1. More formally, if b1⋯bkk1. Note that the value b1⋯bkk is not rounded up or down. For example, the array [1,1,1,2] has an arithmetic mean of 1.25, which is no…

结对-贪吃蛇游戏-开发环境搭建过程

结对编程成员&#xff1a;赵建辉&#xff0c;马壮 搭建环境&#xff1a; 会 html,css,以及java开发知识。 会应用sublime&#xff0c;dw等编辑软件 编写程序阶段&#xff1a; 1.利用html搭建前端页面&#xff0c;构建游戏的页面框架 2.利用js方面的知识编写贪吃蛇游戏代码转载于…

条件、循环、函数定义 练习

a.五角星 import turtleturtle.color(yellow)turtle.begin_fill()for i in range(5): turtle.forward(100) turtle.right(144)turtle.end_fill() b.同心圆 import turtlefor i in range(5): turtle.up() turtle.goto(0,-20*(i1)) turtle.down() turtle.circle(20*(i1)) c.太阳花…

2015年上半年 软件设计师 上午试卷 综合知识-2

2015年上半年 软件设计师 上午试卷 综合知识-2 与算术表达式"&#xff08;a&#xff08;b-c&#xff09;&#xff09;*d" 对应的树是&#xff08;21&#xff09;。 答案&#xff1a; B 本题考查程序语言与数据结构基础知识。 对算术表达式"(a(b-c))*d"求…

PHP base64数据与图片的互相转换

1.解析base64数据成图片 The problem is that data:image/bmp;base64, is included in the encoded contents. This will result in invalid image data when the base64 function decodes it. Remove that data in the function before decoding the string, like so. $base64…

B. Trouble Sort Codeforces Round #648 (Div. 2)

B. Trouble Sort Ashish has n elements arranged in a line. These elements are represented by two integers ai — the value of the element and bi — the type of the element (there are only two possible types: 0 and 1). He wants to sort the elements in non-d…

Python web开发——自定义userprofile(用户描述)

1、新建一个APP 2、查看数据库中系统给我们提供的默认的users的字段含义 ID&#xff1a; 是主键&#xff0c;用户的ID passWord&#xff1a;密码 last_login : 最后一次登录的时间 is_superuser&#xff1a;是否是超级用户&#xff08;VIP&#xff09; username&#xff1a;用户…

滚动字幕Marquee

基本语法 <marquee>滚动文字 </marquee> 文字移动属性的设置 方向 <direction#> #left, right,up,down 方式 <bihavior#> #scroll,由一端滚动到另一端&#xff0c;会重复 slide, 由一端滚动到另一端&#xff0c;不会重复 alternate 在两端之间来回…

D. Solve The Maze Codeforces Round #648 (Div. 2)

D. Solve The Maze Vivek has encountered a problem. He has a maze that can be represented as an nm grid. Each of the grid cells may represent the following: Empty — ‘.’ Wall — ‘#’ Good person — ‘G’ Bad person — ‘B’ The only escape from the maze…

Android之View绘制流程开胃菜---setContentView(...)详细分析

版权声明&#xff1a;本文出自汪磊的博客&#xff0c;转载请务必注明出处。 1 为什么要分析setContentView方法 作为安卓开发者相信大部分都有意或者无意看过如下图示&#xff1a;PhoneWindow,DecorView这些究竟都是些神马玩意&#xff1f;图示的层级关系是怎么来的&#xff1f…

Hibernate查询方式

Hibernate查询方式 1 OID查询 &#xff08;1&#xff09;根据id查询某一条记录&#xff0c;返回对象 2 对象导航查询 &#xff08;1&#xff09;根据id查询某个公司&#xff0c;再查询这个公司里面所有的员工 Company csession.get(Company.class, 1);Set<Worker> set …

Harbour.Space Scholarship Contest 2021-2022 (open for everyone, rated, Div. 1 + Div. 2)(A - D)

A 太简单了&#xff0c;写完就删了B 有很多人暴力搜&#xff0c;或者其他方法&#xff0c;样例不严谨过了&#xff0c;然后就被hack了 #include<bits/stdc.h> #define int long long using namespace std; signed main() {int t;cin>>t;while (t--){string str,s…

Codeforces Round #734 (Div. 3) (A-D1)

A 太简单了&#xff0c;写完就删了B1 #include <bits/stdc.h> using namespace std; #define int long long signed main() {int t;cin >> t;while (t--){int ch[33];memset(ch, 0, sizeof(ch));string str;cin >> str;for (int i 0; i < str.length()…

排序算法之堆排序

一、什么是堆 如果一个完全二叉树的每个节点&#xff0c;都不大于它的子节点&#xff0c;就可以称之为堆。所谓完全二叉树&#xff0c;就是除了叶子节点以外&#xff0c;所有的其他节点&#xff0c;都有完整的左字树和右子树&#xff0c;除了最后一层的非叶子节点以外。 二、堆…

Codeforces Global Round 15 (A-D)没有C

A 太简单&#xff0c;写完删了B 我写的繁了&#xff0c;但是意思是这么个意思&#xff0c;就遍历打擂台一样&#xff0c;找到最后的胜者&#xff0c;然后在遍历一遍找是不是最厉害的 #include <bits/stdc.h> using namespace std; #define int long long int op[200095…

Codeforces Round #434 (Div. 2)【A、B、C、D】

Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding【水】 题意&#xff1a;已知n和k&#xff0c;求n的最小倍数x&#xff0c;要求x后缀至少有k个0。 题解&#xff1a;答案就是10^k和n的最小公倍数。 1 #include<cstdio>2 #include<cstring>3 #include&l…

Codeforces Round #735 (Div. 2)(A-D)没有B

Codeforces Round #735 (Div. 2) A 一道小思维题 #include <bits/stdc.h> using namespace std; #define int long long const int N 1000100; int a[N]; signed main() {int t;cin>>t;while(t--){int n;cin>>n;int cou 0;for (int i1;i<n;i){cin>&…

Educational Codeforces Round 112 (Rated for Div. 2)(A-D)

Educational Codeforces Round 112 (Rated for Div. 2) A 我写的挺烦的&#xff0c;其实判断一下奇偶数和有没有a>0就行 #include <bits/stdc.h>using namespace std;#define int long longsigned main(){int t;cin>>t;while (t--){int n;cin>>n;int a n…