一、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. leetcode1016

    class Solution(object): def queryString(self, S: str, N: int) -> bool: return all(S.find(bin(i)[2 ...

  2. newCachedThreadPool使用案例

    newCachedThreadPool 缓存默认60s 猜下你的结果 package com.juc.threadpool; import java.util.concurrent.ExecutorS ...

  3. python中time模块和datetime模块

    time模块和datetime模块 时间分为三种模式(time 模块) 时间戳   (time.time()) 格式化字符串 (time.strftime(%Y-%m-%d %H:%M:%S %p)) ...

  4. How to Pronounce TH after N or Z

    How to Pronounce TH after N or Z Share Tweet Share Tagged With: Linking Consonant to Consonant The T ...

  5. 深入jUI(DWZ)

    -----------------------------------------------------------------------------主页面index.html <html& ...

  6. [Linux].deb软件包:wine-qq2013-longeneteam安装与卸载

    --------------------------------------------------------------------------------------------- 首先切换到r ...

  7. angularjs 与 UEditor开发,添加directive,保证加载顺序正常

    'use strict'; angular.module('app.core').directive('ueditor', [function () { return { restrict: 'A', ...

  8. ORACLE数据库 常用命令和Sql常用语句

    ORACLE 账号相关 如何获取表及权限 1.COPY表空间backup scottexp登录管理员账号system2.创建用户 create user han identified(认证) by m ...

  9. Hibernate学习笔记2.2(Hibernate基础Annotation配置)

    如果数据库表名与类名不一致 可以用使用 @Table(name="_teacher") 来指定表名,没有就会自己创建 也可以在配置文件上修改 为class添加table属性 如果什 ...

  10. Working with the Dynamic Type in C#

    Working with the Dynamic Type in C# https://www.red-gate.com/simple-talk/dotnet/c-programming/workin ...