⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apacheconfig.java

📁 低版本的tomcat 对于有些老版本的应用还真的需要老版的中间件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        mod_jk.println("# JkSESSIONIndicator SSL_SESSION_ID");        
        mod_jk.println("# ");        
        mod_jk.println("# What is the indicator for client SSL cipher suit (default is SSL_CIPHER)");        
        mod_jk.println("# JkCIPHERIndicator SSL_CIPHER");
        mod_jk.println("# ");        
        mod_jk.println("# What is the indicator for the client SSL certificated (default is SSL_CLIENT_CERT)");        
        mod_jk.println("# JkCERTSIndicator SSL_CLIENT_CERT");
        mod_jk.println("# ");        
        mod_jk.println("#                                                                 #");        
        mod_jk.println("###################################################################");
        mod_jk.println();


        mod_jk.println("#");        
        mod_jk.println("# Root context mounts for Tomcat");
        mod_jk.println("#");        
        mod_jk.println("JkMount /*.jsp ajp12");
        mod_jk.println("JkMount /servlet/* ajp12");
        mod_jk.println();

	    // Set up contexts
	    // XXX deal with Virtual host configuration !!!!
	    enum = cm.getContexts();
	    while (enum.hasMoreElements()) {
		Context context = (Context)enum.nextElement();
		String path  = context.getPath();
		String vhost = context.getHost();

		if( vhost != null ) {
		    // Generate Apache VirtualHost section for this host
		    // You'll have to do it manually right now
		    // XXX
		    continue;
		}
		if( path.length() > 1) {

		    // It's not the root context
		    // assert path.startsWith( "/" )

		    // Calculate the absolute path of the document base
		    String docBase = context.getDocBase();
		    if (!FileUtil.isAbsolute(docBase))
			docBase = tomcatHome + "/" + docBase;
		    docBase = FileUtil.patch(docBase);
			if (File.separatorChar == '\\')
				docBase = docBase.replace('\\','/');	// use separator preferred by Apache

		    // Static files will be served by Apache
		    pw.println("Alias " + path + " \"" + docBase + "\"");
		    pw.println("<Directory \"" + docBase + "\">");
		    pw.println("    Options Indexes FollowSymLinks");
		    pw.println("</Directory>");

		    // Dynamic /servet pages go to Tomcat
		    pw.println("ApJServMount " + path +"/servlet" + " " + path);

		    // Deny serving any files from WEB-INF
		    pw.println("<Location \"" + path + "/WEB-INF/\">");
		    pw.println("    AllowOverride None");
		    pw.println("    deny from all");
		    pw.println("</Location>");
			// For Windows, use Directory too. Location doesn't work unless case matches
			if (File.separatorChar == '\\') {
				pw.println("<Directory \"" + docBase + "/WEB-INF/\">");
				pw.println("    AllowOverride None");
				pw.println("    deny from all");
				pw.println("</Directory>");
			}

		    // Deny serving any files from META-INF
			pw.println("<Location \"" + path + "/META-INF/\">");
			pw.println("    AllowOverride None");
			pw.println("    deny from all");
			pw.println("</Location>");
			// For Windows, use Directory too. Location doesn't work unless case matches
			if (File.separatorChar  == '\\') {
				pw.println("<Directory \"" + docBase + "/META-INF/\">");
				pw.println("    AllowOverride None");
				pw.println("    deny from all");
				pw.println("</Directory>");
			}
		    pw.println();


			// Static files will be served by Apache
            mod_jk.println("#########################################################");		    
            mod_jk.println("# Auto configuration for the " + path + " context starts.");
            mod_jk.println("#########################################################");		    
            mod_jk.println();
            
            mod_jk.println("#");		    
            mod_jk.println("# The following line makes apache aware of the location of the " + path + " context");
            mod_jk.println("#");                        
		    mod_jk.println("Alias " + path + " \"" + docBase + "\"");
		    mod_jk.println("<Directory \"" + docBase + "\">");
		    mod_jk.println("    Options Indexes FollowSymLinks");
		    mod_jk.println("</Directory>");
            mod_jk.println();            

		    // Dynamic /servet pages go to Tomcat
            mod_jk.println("#");		    
            mod_jk.println("# The following line mounts all JSP files and the /servlet/ uri to tomcat");
            mod_jk.println("#");                        
		    mod_jk.println("JkMount " + path +"/servlet/* ajp12");
		    mod_jk.println("JkMount " + path +"/*.jsp ajp12");


		    // Deny serving any files from WEB-INF
            mod_jk.println();            
            mod_jk.println("#");		    
            mod_jk.println("# The following line prohibits users from directly accessing WEB-INF");
            mod_jk.println("#");                        
		    mod_jk.println("<Location \"" + path + "/WEB-INF/\">");
		    mod_jk.println("    AllowOverride None");
		    mod_jk.println("    deny from all");
		    mod_jk.println("</Location>");
			if (File.separatorChar == '\\') {
				mod_jk.println("#");		    
				mod_jk.println("# Use Directory too. On Windows, Location doesn't work unless case matches");
				mod_jk.println("#");                        
				mod_jk.println("<Directory \"" + docBase + "/WEB-INF/\">");
				mod_jk.println("    AllowOverride None");
				mod_jk.println("    deny from all");
				mod_jk.println("</Directory>");
			}

			// Deny serving any files from META-INF
        	mod_jk.println();            
        	mod_jk.println("#");		    
        	mod_jk.println("# The following line prohibits users from directly accessing META-INF");
        	mod_jk.println("#");                        
			mod_jk.println("<Location \"" + path + "/META-INF/\">");
			mod_jk.println("    AllowOverride None");
			mod_jk.println("    deny from all");
			mod_jk.println("</Location>");
			if (File.separatorChar == '\\') {
				mod_jk.println("#");		    
				mod_jk.println("# Use Directory too. On Windows, Location doesn't work unless case matches");
				mod_jk.println("#");                        
				mod_jk.println("<Directory \"" + docBase + "/META-INF/\">");
				mod_jk.println("    AllowOverride None");
				mod_jk.println("    deny from all");
				mod_jk.println("</Directory>");
			}
		    mod_jk.println();

            mod_jk.println("#######################################################");		    
            mod_jk.println("# Auto configuration for the " + path + " context ends.");
            mod_jk.println("#######################################################");		    
            mod_jk.println();

		    // XXX check security
		    if( false ) {
			pw.println("<Location " + path + "/servlet/ >");
			pw.println("    AllowOverride None");
			pw.println("   AuthName \"restricted \"");
			pw.println("    AuthType Basic");
			pw.println("    AuthUserFile conf/users");
			pw.println("    require valid-user");
			pw.println("</Location>");
		    }

	        // XXX ErrorDocument

		    // XXX mime types - AddEncoding, AddLanguage, TypesConfig
		} else {
		    // the root context
		    // XXX use a non-conflicting name
		    pw.println("ApJServMount /servlet /ROOT");
		}

	    }

	    pw.close();
	    mod_jk.close();        
	} catch( Exception ex ) {
	    //	    ex.printStackTrace();
	    //throw new TomcatException( "Error generating Apache config", ex );
	    System.out.println("Error generating automatic apache configuration " + ex);
	    ex.printStackTrace(System.out);
	}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -