seige
$ wget http://www.joedog.org/pub/siege/siege-latest.tar.gz
./configure --with-ssl=/usr/bin/openssl
make
make install
siege -V
yum install mod_ssl openssl
http://jna.java.net/
jna 에 관심있으신분들 사용하시길 ^^;;
jna 는 jni 처럼 dll 에있는 함수를 사용하는겁니다.
다른점이 있다면 jni 는 직접 dll 을 만들어서 해야하지만
jna 는 그냥 dll를 호출할수 있습니다
예로 자바를 user32.dll 로 프로세스를 후킹할려면 이걸로 가능하다고 하네요 ^^...
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
/** Simple example of native library declaration and usage. */
public class HelloWorld {
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);
void printf(String format, Object... args);
}
public static void main(String[] args) {
CLibrary.INSTANCE.printf("Hello, World\n");
for (int i = 0; i < args.length; i++) {
CLibrary.INSTANCE.printf("Argument %d: %s\n", i, args[i]);
}
}
}
위예제는 위키에 등록된 예제를 퍼온것입니다.
C 에있는 printf 를 호출하는것이죠.
Apache에서 proxy를 이용하여 Tomcat으로 redirect 시킬 경우
path가 안맞아서 쿠키가 먹통이 되는 경우가 생김
httpd.conf
ProxyPass / http://localhost:8080/abc
http://abc.mrjh.com/ 도메인에 위 예처럼 redirect 시키면
톰켓에서 생성되는 쿠키 JSESSIONID의 path는 /abc로 잡히고
아파치에서는 /로 쿠키를 인식하기때문에 서로 인식이 안되는 현상이 발생함
이때 톰켓에서 아래처럼 셋팅해주면 Cookie Path를 무조건 /로 잡아줌
conf/server.xml
connectionTimeout="20000"
emptySessionPath="true"
redirectPort="8443" />
위 예제는 Tomcat 6.x 까지 적용되며 Tomcat 7.x 에서는 위의 설정은 적용되지 않으며 아래와 같이 옵션을 줘야함
<Context .............. sessionCookiePath="/" ....... ></Context>
참고
http://tomcat.apache.org/migration.html#Session_cookie_configuration
<%
ServletContext ctx = application.getContext("/context-1");
Integer counter = (Integer)ctx.getAttribute("counter");
if (counter == null) {
counter = 0;
}
counter++;
request.setAttribute("counter", counter);
ctx.setAttribute("counter", counter);
%>
<h1>Context-1</h1>
<h1>현재 카운터는 ${counter}입니다.</h1>
<%
ServletContext ctx = application.getContext("/context-1");
Integer counter = (Integer)ctx.getAttribute("counter");
if (counter == null) {
counter = 0;
}
counter++;
request.setAttribute("counter", counter);
ctx.setAttribute("counter", counter);
%>
<h1>Context-1</h1>
<h1>현재 카운터는 ${counter}입니다.</h1>
Imagine you're developping a web site that manages subdomains for your users, in such a way that all your users automatically get a http://user1.example.com orhttp://user2.example.com subdomain.
In order to keep the normal session available on all the subdomains, one just needs to make the session cookie associated to the smallest common domain, in this exemple, the example.com domain, so that www.example.com share the same cookie with all the other http://[whatever].example.com subdomains. Piece of cake:cookie.setDomain("example.com"), right? Almost. Just, not in a servlet container. Because, you can't.
It's amazing, but in a servlet container, you just can't tell which domain the JSESSIONID cookie is associated to. Unfortunately, Tomcat provides no container-specific way to modify this behaviour.
So, here's a simple patch that fixes the issue. It's not suited for all purpose, it just removes any www prefix that appears in the hostname, and use it as cookie domain. If there's no www prefix, the normal behaviour applies.
In apache-tomcat-6.0.18-src/java/org/apache/catalina/connector/Request.java, find the configureSessionCookie() method, and replace it with this one:
/** * Configures the given JSESSIONID cookie. * * @param cookie The JSESSIONID cookie to be configured */ protected void configureSessionCookie(Cookie cookie) { cookie.setMaxAge(-1); String contextPath = null; if (!connector.getEmptySessionPath() && (getContext() != null)) { contextPath = getContext().getEncodedPath(); } if ((contextPath != null) && (contextPath.length() > 0)) { cookie.setPath(contextPath); } else { cookie.setPath("/"); } if (isSecure()) { cookie.setSecure(true); } // CHANGES BELOW }