I'm starting to migrate from apache2 to nginx.
I have a jboss application on localhost whick used to be reverse proxyfied by apache2.
My nginx site redirect to jboss by I can't manage to stay connected and I am redirected by jboss to the login page.
I suspect a problem with the jsession but cant manage to get it right ... any help would be greatly appreciated.
Here's a sample of my old apache2 vhost.
<VirtualHost thisis.mydomain.fr:80>
ServerName thisis.mydomain.fr
Redirect / https://thisis.mydomain.fr
</VirtualHost>
<VirtualHost thisis.mydomain.fr:443>
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/apache2/ssl/mycert.pem
SSLCertificateKeyFile /etc/apache2/ssl/mycert.key
ServerSignature On
ProxyVia on
ProxyPreserveHost On
ProxyRequests Off
ServerAdmin [email protected]
ServerName thisis.mydomain.fr
ServerAlias http://thisis.mydomain.fr
ProxyPass / http://127.0.0.1:8080/myapp-webctx/ timeout=3600
ProxyPassReverse / http://127.0.0.1:8080/myapp-webctx/
ProxyPassReverseCookiePath /myapp-webctx /
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
My attempt at converting it to a nginx vhost is like this : /etc/nginx/proxy.conf
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;
# Enable GZip compression
gzip on;
gzip_http_version 1.1;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6] \.";
gzip_types text/html text/css text/xml application/x-javascript application/atom+xml text/plain
gzip_vary on;
myvhost.conf
server {
listen 80;
server_name my.domain.fr;
return 301 https://$server_name$request_uri;
}
# the nginx server instance
server {
listen 443 ;
server_name my.domain.fr myapp;
access_log /var/log/nginx/myapp.log;
ssl_certificate /etc/nginx/ssl/myapp.pem;
ssl_certificate_key /etc/nginx/ssl/myapp.key;
ssl_session_timeout 5m;
include /etc/nginx/proxy.conf;
location / {
proxy_cookie_path /myapp-ctx/ / ;
proxy_cookie_path / /myapp-ctx ;
proxy_cookie_domain 127.0.0.1 my.domain.fr;
if ($http_cookie ~* "jsessionid=([^;]+)(?:;|$)") {
set $co "jsessionid=$1i; Path=/";
}
proxy_set_header Cookie "$co";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect / http://127.0.0.1:8080/myapp-ctx/;
proxy_pass http://127.0.0.1:8080/myapp-ctx/;
}
}
Regards
Tony