`

Nginx配置AJP

 
阅读更多
*请使用源码方式安装Nginx!

下载Nginx及必须的包

Step 1:
      mkdir -p /usr/src/nginx && cd /usr/src/nginx

     apt-get install unzip 
  
		wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz

		tar zxvf openssl-1.0.1j.tar.gz
		
		wget http://www.zlib.net/zlib-1.2.11.tar.gz

		tar zxvf zlib-1.2.11.tar.gz

		wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.zip
		unzip pcre-8.42.zip

		wget https://codeload.github.com/yaoweibin/nginx_ajp_module/zip/master -O nginx_ajp_module-master.zip

		unzip nginx_ajp_module-master.zip

		wget http://nginx.org/download/nginx-1.4.4.tar.gz
                
                tar nginx-1.4.4.tar.gz 


Step 2:
       配置及编译Nginx

cd nginx-1.4.4

./configure  --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --user=nginx --group=nginx --http-log-path=/usr/local/nginx/logs/httpd.log --http-client-body-temp-path=/usr/local/nginx/temp/http-client-body-temp --http-proxy-temp-path=/usr/local/nginx/temp/http-proxy-temp --without-http_fastcgi_module --http-uwsgi-temp-path=/usr/local/nginx/temp/http-uwsgi-temp --http-scgi-temp-path=/usr/local/nginx/temp/http-scgi-temp --with-pcre=/usr/src/nginx/pcre-8.42 --with-zlib=/usr/src/nginx/zlib-1.2.11/  --add-module=/usr/src/nginx/nginx_ajp_module-master/ --with-openssl=/usr/src/nginx/openssl-1.0.1j/ --with-http_ssl_module

make

make install





*如果编译遇到问题报错


-getpwnam(“nginx”) failed

   没有安装nginx用户导致的无法启动

useradd -s /sbin/nologin -M nginx
id nginx



报错
nginx: [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or direc

sudo mkdir  -p /usr/local/nginx/temp/http-client-body-temp    




---------------------------------------------------------------------------------



安装Tomcat或其他Web容器


NginxAPJ 简单配置

nginx.con

	
          location /{
       
		ajp_connect_timeout 120s;
		ajp_keep_conn on;
		ajp_pass 127.0.0.x:8009; 
	 }

           
分享到:
评论
4 楼 沈寅麟 2018-12-29  
conf.d/default.config
-----------------------
upstream tomcats {
        server 172.17.0.1:8009;
         #srun_id=jvm1;
         #jvm_route $cookie_JSESSIONID reverse;
        keepalive 10;
}
server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

       location / {
           ajp_pass tomcats;
           ajp_connect_timeout 120s; 
           ajp_keep_conn on;
        }         
       

        #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;
    #    }
    #}
3 楼 沈寅麟 2018-12-29  

配置完nginx,在启动的时候遇到如下问题:
nginx: [emerg] "upstream" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:7

配置nginx.conf,如下:
upstream con {
    server 127.0.0.1:8080;
}

解决办法:

upstream backend 位置放错了, upstream位置应该放在http模块里面 但必须是在server模块的外面
2 楼 沈寅麟 2018-09-05  
孔已己 写道
ajp不是一个插件么

是的  https://github.com/yaoweibin/nginx_ajp_module
1 楼 孔已己 2018-08-29  
ajp不是一个插件么

相关推荐

    nginx配置ajp-附件资源

    nginx配置ajp-附件资源

    AJP for Nginx

    配置Nginx以使用AJP模块,你需要在Nginx配置文件中定义一个AJP监听器,并设置相应的连接参数,例如: ```nginx http { upstream backend { server 127.0.0.1:8009; # Tomcat的AJP端口 } server { listen 80; ...

    Nginx/Httpd反代tomcat配置教程

    其中对于tomcat连接器来说,它分三类,一类是http连接器,一类是https连接器,一类是ajp连接器;通常tomcat作为应用服务器,我们不建议也不应该让tomcat直接面向客户端提供服务;因此进入tomcat的访问就只有其他反代...

    Nginx+Tomcat配置3台负载均衡及https.docx

    - 如果需要AJP协议支持,可以配置AJP连接器,监听8002端口。 ``` <Connector port="8002" protocol="AJP/1.3" redirectPort="8441" /> ``` 2. **Tomcat 8081** - 对于第二台服务器上的Tomcat,将`Server`标签...

    nginx和tomcat配置SSL和负载均衡配置

    ### Nginx 和 Tomcat 配置 SSL 与负载均衡详解 #### 一、Nginx 支持 SSL 的确认方法 Nginx 支持 SSL 加密是现代 Web 服务器的基本需求之一,确保数据传输的安全性。首先,我们需要确认当前安装的 Nginx 版本是否...

    nginx替代方案,nginx代替apache与jboss

    - **简单的配置文件**:Nginx 的配置文件简洁明了,易于理解和维护。 - **成本效益**:Nginx 是一款开源软件,可以免费使用,与购买 F5 BIG-IP、NetScaler 等商业硬件负载均衡设备相比,成本大幅降低。 - **灵活的 ...

    NginxAJPModule.zip

    这是一个 Nginx 的模块,用来使用 Ajp 协议连接后端的 Tomcat ,相当于 Apache 上的 mod_jk 模块。 配置方法: upstream tomcats { server 127.0.0.1:8009 srun_id=jvm1; jvm_route $cookie_JSESSIONID reverse...

    Nginx+Tomcat配置

    【Nginx+Tomcat配置】的组合是常见的Web服务器架构,主要用于提高网站的性能和负载均衡能力。...在实际部署中,还需要配置Nginx与Tomcat之间的通信,如通过AJP或HTTP代理,以及设置负载均衡策略,如轮询、权重分配等。

    nginx 1.17.10.1 Unicorn.zip

    【Nginx 1.17.10.1 Unicorn.zip】是一个针对Windows服务器的Nginx配置包,其中包含了Nginx服务器的核心组件以及一些附加功能。Nginx是一款高性能、轻量级的Web服务器/反向代理服务器,以其高并发处理能力、低内存...

    Nginx+Tomcat配置.pdf

    Nginx+Tomcat 配置 Nginx 是一个轻量级的 Web 服务器,相比 Apache,有着更好的性能和更少的资源占用。Nginx 的主要特点是速度快、占用资源少、支持 epoll、rewrite 和静态文件能力非常强大,非常适合作为整个网站...

    nginx + tomcat 集群配置

    nginx + tomcat 集群配置 负载 nginx 下载地址: http://nginx.org/en/download.html 联合tomcat 实现集群 windows: Nginx.conf 配置 //见文件夹下面的nginx.conf 更改tomcat的配置: 第一处端口...

    Nginx结合Tomcat的jar包

    以下是使用Nginx配置负载均衡的基本步骤: 1. 安装Nginx并更新配置文件:在Nginx的配置文件(通常位于`/etc/nginx/nginx.conf`)中,创建一个新的server块,定义监听的端口和代理设置。 2. 配置上游服务器:在...

    nginx 1.17.9.1 Unicorn.zip

    8. `ajp_temp` - 这个目录可能用于存放Apache Jserv Protocol (AJP)的临时文件,表明Nginx可能配置了与Apache的AJP连接器进行通信。 总结来说,这个压缩包提供了一套完整的Nginx 1.17.9.1与Unicorn在Windows上的...

    linux下nginx+tomcat负载均衡配置

    ### Linux 下 Nginx + Tomcat 负载均衡配置详解 #### 一、Nginx 安装 Nginx 是一款轻量级的 Web 服务器 / 反向代理服务器及电子邮件(IMAP/POP3)代理服务器,其特点是占有内存少,并发能力强。在 Linux 系统上...

    nginx_mod_cluster_module:在原始mod_cluster的基础上,将功能mod_cluster实现为nginx。 用于动态添加Nginx上游路由配置的API

    名称 nginx_mod_cluster_module-基于原始mod_... - Add support to AJP using https://github.com/yaoweibin/nginx_ajp_module. (probably never will do it) - Sticky session based on URL param 工作功能: -

    nginx 1.13.6.1 for windows

    - **ajp_temp** 文件夹:可能是用于存储与 Apache AJP 协议相关的临时文件,如果 Nginx 需要与 Apache 集成,这个目录将发挥作用。 **4. 使用指南** - **Readme nginx-win version.txt** 和 **FAQ nginx-win ...

    nginx 1.7.11.3 Gryphon.zip

    `ajp_temp`目录则可能用于存储Apache JSP处理过程中产生的临时文件,表明Nginx可以与Apache的AJP模块协同工作,实现后端负载均衡。 配置Nginx RTMP模块,首先需要在`nginx.conf`中启用RTMP模块,添加以下配置: ```...

    nginx+tomcat集群

    4. **Nginx配置负载均衡**: - 编辑Nginx配置文件(通常为`/opt/nginx/conf/nginx.conf`),在HTTP或Server段下添加Upstream块,定义后端Tomcat服务器组,如: ``` upstream backend { server 127.0.0.1:8080; ...

    Nginx+Tomcat+Session-高性能群集搭建.doc

    - 修改Tomcat的server.xml配置文件,开启AJP端口,以便Nginx通过AJP协议与Tomcat通信。 5. **配置Session共享**: - 可以通过Nginx的jvmroute模块实现基于cookie的Session粘滞,使用户请求始终发送到同一台Tomcat...

Global site tag (gtag.js) - Google Analytics