一、Jetty搭建

1)上传jetty.tar,并且解压(支持war和文件夹)

[root@localhost home]# tar -xvf jetty.tar

[root@localhost home]# ls
jetty  jetty.tar

2)修改jetty-start.d对应程度的端口

root@localhost start.d]# vi http.ini 
#
# Initialize module http
#
--module=http
## HTTP Connector Configuration
# HTTP port to listen on
jetty.port=8081
# HTTP idle timeout in milliseconds
http.timeout=30000
# HTTP Socket.soLingerTime in seconds. (-1 to disable)
# http.soLingerTime=-1

3)Jetty-webapps 创建映射文件

[root@localhost channel-openapi-reroute]# pwd
/data/channel-openapi-reroute

[root@localhost webapps]# ls

channel-openapi-reroute.xml  README.TXT

[root@localhost webapps]# vi channel-openapi-reroute.xml (支持war和文件夹)

  1.  
    [root@localhost webapps]# vi channel-openapi-reroute.xml
  2.  
     
  3.  
    <?xml version="1.0" encoding="UTF-8"?>
  4.  
    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
  5.  
     
  6.  
    <!-- ==================================================================
  7.  
    Configure and deploy the test web application in $(jetty.home)/webapps/test
  8.  
     
  9.  
    Note. If this file did not exist or used a context path other that /test
  10.  
    then the default configuration of jetty.xml would discover the test
  11.  
    webapplication with a WebAppDeployer. By specifying a context in this
  12.  
    directory, additional configuration may be specified and hot deployments
  13.  
    detected.
  14.  
    ===================================================================== -->
  15.  
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
  16.  
    <span style=""> <Set name="contextPath">/</Set>
  17.  
    <Set name="war">/data/channel-openapi-reroute</Set></span>
  18.  
     
  19.  
    </Configure>

4)启动jetty

[root@localhost jetty]# ./bin/jetty.sh start

二、Nginx中配置文件

1.在vhost下面创建一个www.openapi.net.conf 文件

[root@localhost vhost]# pwd
/usr/local/nginx/conf/vhost
[root@localhost vhost]# vi www.openapi.net.conf

server {
        listen      80;
        server_name www.openapi.net;

access_log  /data/logs/channel-openapi-reroute/openapi_access.log  access;
        error_log   /data/logs/channel-openapi-reroute/openapi_error.log  crit;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                    root   /usr/local/nginx/html;
        }

location /api {
            proxy_pass      http://127.0.0.1:8081;
            proxy_redirect  off;
            proxy_set_header        Host    $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

2.Nginx重新加载

[root@localhost vhost]# service nginx reload

3.客户端添加host(C:\Windows\System32\drivers\etc\hosts),请求java服务

192.168.13.199  www.openapi.net

备注:

1.Nginx映射的端口与Jetty配置的端口要一致

2.Ngin的配置文件URL命名要与接口文档一致(否则请求失败)

3.一个jetty跑一个java服务

JETTY+NGINX的更多相关文章

  1. 总结:Apache/Tomcat/JBOSS/Jetty/Nginx区别 .

    总结:Apache/Tomcat/JBOSS/Nginx区别 .1.Apache是Web服务器,Tomcat是应用(Java)服务器.Tomcat在中小型系统和并发访问用户不是很多的场合下被普遍使用. ...

  2. linux(centos) 项目部署阶段相关命令汇总

    1.ssh免密码登陆主要命令cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys-->添加公钥service sshd restart -- ...

  3. 161118、linux(centos) 项目部署阶段相关命令汇总

    1.ssh免密码登陆 主要命令 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys-->添加公钥 service sshd restart ...

  4. Java面试 32个核心必考点完全解析

    目录 课程预习 1.1 课程内容分为三个模块 1.2 换工作面临问题 1.3 课程特色 课时1:技术人职业发展路径 1.1 工程师发展路径 1.2 常见技术岗位划分 1.3 面试岗位选择 1.4 常见 ...

  5. 一个完整Java Web项目背后的密码

    前言 最近自己做了几个Java Web项目,有公司的商业项目,也有个人做着玩的小项目,写篇文章记录总结一下收获,列举出在做项目的整个过程中,所需要用到的技能和知识点,带给还没有真正接触过完整Java ...

  6. 做一个完整的Java Web项目需要掌握的技能[转]

    转自:http://blog.csdn.net/JasonLiuLJX/article/details/51494048 最近自己做了几个Java Web项目,有公司的商业项目,也有个人做着玩的小项目 ...

  7. 做一个完整的Java Web项目需要掌握的技能

    最近自己做了几个JavaWeb项目,有公司的商业项目,也有个人做着玩的小项目,写篇文章记录总结一下收获,列举出在做项目的整个过程中,所需要用到的技能和知识点,带给还没有真正接触过完整Java Web项 ...

  8. 拜托,别再问我怎么自学 Java 了!和盘托出

    假如有那么残酷的一天,我不小心喝错了一瓶药,一下子抹掉了我这十多年的编程经验,把我变成了一只小白.我想自学 Java,并且想要找到一份工作,我预计需要 6 个月的时间,前提条件是每天都处于高效率的学习 ...

  9. Prometheus基础

    监控系统作用 监控系统主要用于保证所有业务系统正常运行, 和业务的瓶颈监控. 需要周期性采集和探测. 采集的详情 采集: 采集器, 被监控端, 监控代理, 应用程序自带仪表盘, 黑盒监控, SNMP. ...

随机推荐

  1. jmap dump文件压缩后失效

    最近线上出问题,于是用jmap -dump拿到dump文件,再linux压缩后拿到windows下无效,后来又直接拿了一个没有压缩的竟然可以用...坑啊!~

  2. leetcode994

    public class Solution { ; ; ; ; ; Queue<int[]> Q = new Queue<int[]>(); int[,] TagGrid; p ...

  3. Valgrind简单用法 (转)

    转自 http://www.cnblogs.com/sunyubo/archive/2010/05/05/2282170.html Valgrind的主要作者Julian Seward刚获得了今年的G ...

  4. Hadoop 3.0 安装

    1.      下载Hadoop 3.0 http://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.0.0/hadoop-3. ...

  5. 09_组件三大属性(3)_refs和事件处理

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. iOS设计标注处理方法

    如果设计只给3x的设计图 在做2x适配时有几种处理方法: 按逻辑像素,大小不变,比如3x手机上一张图的逻辑像素设为24x24point,那么2x手机上这张图的大小也设为24x24point,一般适用于 ...

  7. Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher

    Context namespace element 'annotation-config' and its parser class [org.springframework.context.anno ...

  8. cx_Oracle.DatabaseError: DPI-1047

    ODPI-C Installation¶ Overview Oracle Client and Database Versions Linux Oracle Instant Client Zip Or ...

  9. TypeScript语言学习笔记(1)

    基本类型 // 布尔型(Boolean) let isDone: boolean = false; // 数值型(Number) let decimal: number = 6; let hex: n ...

  10. 虚拟机安装centos6.6全步骤

    1.首先要下载一个centos的iso镜像,我是用虚拟机VMware来安装的,用VMware最好创建一个空白硬盘. 2.创建完毕再设置里面挂载iso的centos系统文件. 3.进入到这个页面: 说明 ...