发表于: 2018-04-01 22:39:49

1 426


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

配置了nginx.conf反向代理tomcat

主要配置是

server

        {

                listen       80;

                server_name  localhost;

                #index index.jsp; #设定访问的默认首页地址

                #root  /task; #设定网站的资源存放路径

                #limit_conn   crawler  20;   

                location / {

                        root /task/task2_SpringMVC/;

                        #index index.jsp;

                        proxy_pass http://127.0.0.1:8080;

                }

                #定义访问日志的写入格式

                #log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

                #'$status $body_bytes_sent "$http_referer" '

                #'"$http_user_agent" $http_x_forwarded_for';

                #access_log  /usr/local/nginx/logs/localhost.log access;#设定访问日志的存放路径

        }

}

listen监听 80 tcp端口

这边我只配置了一个tomcat,所以server_name 就只写了一个localhost

root指定项目目录

proxy_pass 指定代理转发到8080端口


同时tomcat配置server.xml

在<Host>标签中加入<Context path="" docBase="/task/task2_SpringMVC" debug="0" reloadable="true"/>

消除url中的项目名

<Host name="localhost"  appBase="/task"

            unpackWARs="true" autoDeploy="true">

        <Context path="" docBase="/task/task2_SpringMVC" debug="0" reloadable="true"/>


在项目中加入静态元素

首先建立静态文件目录

在/jsp/list.jsp中加上

<img src="../img/delete.jpg" alt="111">

..表示父目录下的img目录,这是相对路径。

绝对路径需要完整目录,且以/开头。


做了动静分离。

部署到线上没有问题。

明天计划的事情:(一定要写非常细致的内容) 

加一个tomcat做负载均衡

写几个简化操作的脚本。

遇到的问题:(遇到什么困难,怎么解决的)

之前在nginx.conf中有个ssl相关的参数,一直没注释,总跑不起来。。。今天才注意到,注释了就能转发到tomcat了

 

收获:(通过今天的学习,学到了什么知识)

做了动静分离

写了start.sh  stop.sh deploy.sh


返回列表 返回列表
评论

    分享到