`

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-附件资源

    Nginx/Httpd反代tomcat配置教程

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

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

    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_upstream_check_module-master.zip

    借助淘宝技术团队开发的nginx模快nginx_upstream_check_module来检测后方realserver的健康状态,如果后端服务器不可用,则会将其踢出upstream,所有的请求不转发到这台服务器。当期恢复正常时,将其加入upstream。 ...

    Apache2.2以上版本与Tomcat整合配置及负载均衡实现

    修改apache配置文件httpd.conf 启用mod_proxy_ajp 代码如下: #LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so 把这两行前面的#去掉即可 然后在末尾加上 ...

    apache+tomcat 实现负载均衡

    在Apache中通过mod_proxy_ajp模块发送AJP数据,另外一端的服务器需要实现AJP协议,能够接受mod_proxy_ajp模块发送的AJP协议数据,在接受到AJP协议数据后做适当处理,并能够将处理结果以AJP协议方式发送回给mod_proxy_...

    tomcat6_apache2.2_ajp 负载均衡加集群实战分享

    tomcat服务器:均配置相同的应用。 1.集群名:balancer://tomcatcluster 2.三台集群服务器ip: IP_1:192.168.1.31 IP_2:192.168.1.32 IP_3:192.168.1.33 3.测试应用程序test文件夹放在tomcat6的webapps目录下 操作...

    Eclipse开发分布式商城系统+完整视频代码及文档

    │ 12.nginx的配置文件-通过端口号区分虚拟机.avi │ 13.通过域名配置虚拟机.avi │ 淘淘商城第二天笔记.docx │ ├─03.第三天 │ 01.课程回顾.avi │ 02.课程计划.avi │ 03.什么是反向代理.avi │ 04.nginx的...

Global site tag (gtag.js) - Google Analytics