• Nginx


    首先下载Nginx,这里电脑太垃圾,没法装虚拟机,所以只能用Windons版本的Nginx。

    安装包下载地址:http://nginx.org/en/download.html

        

    下载下来,然后解压;

         

    然后双击 nginx.exe就可以了。

    在浏览器中输入:http://127.0.0.1/ 或者 loclahost,出现以下页面标示成功:

         

    一开始以为windows上,nginx的命令没法使用,试了一下,还可以使用

         

    运行停止命令:nginx.exe -s stop

         

    好的,到这里,Nginx就算是安装完毕了。

    既然是要测试Nginx,那咱们的有两个HTTP程序,用来发布服务。

    为了方便,我使用的是SpringBoot

         

    两个http程序发布的地址是:

    http://localhost:9000/sayInfo

    http://localhost:9001/hello

    接下来,先把刚才启动的nginx停止,然后打开nginx-1.14.0conf 目录下的nginx.conf文件,

    友情提醒下,最好先备份一份,供以后学习继续使用。

    删除无用配置之后,我的配置文件是这样子的:

    worker_processes  1;
     
    events {
        worker_connections  1024;
    }
     
     
    http {
        include       mime.types;
        default_type  application/octet-stream;
        
        sendfile        on;
        server {
            listen       80;
            server_name  localhost;
     
            location / {
                root   html;
                index  index.html index.htm;
            }
            
            location /sayInfo {
                proxy_pass http://localhost:9000/sayInfo;
            }
            
            location /hello {
                proxy_pass http://localhost:9001/hello;
            }
            
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }


    监听80端口

         

    根据不同的url路径,走不同的请求分支

    保存配置文件,接着启动nginx;

    由于咱们监听80端口,所以url变成了这样子:

    http://127.0.0.1/sayInfo

    http://127.0.0.1/hello

       

    nginx帮我们做了请求转发


    转载至:https://blog.csdn.net/Simba_cheng/article/details/81839271

  • 相关阅读:
    面试技巧——经典面试问题回答思路
    Linux试题及答案(一)
    面试中的问到薪资问题怎么回答?
    LoadRunner监控Linux
    面试时如何解释被裁原因
    可持久化数组
    洛谷P2286宠物收养场·改
    改博客的背景
    洛谷P2286宠物收养场
    阶乘的0
  • 原文地址:https://www.cnblogs.com/mh-study/p/10112506.html
Copyright © 2020-2023  润新知