› Foros › PC › Software libre
(partner1 - tomcatServer1)
http://myServerIp1:8080/ ->tomcat index
http://myServerIp1:8080/webapp1 ->webapp1(main)
http://myServerIp1:8080/webapp2 ->webapp2
(partner2 - tomcatServer2)
http://myServerIp2:8080/ ->tomcat index
http://myServerIp2:8080/webapp1 ->webapp1(main)
http://myServerIp2:8080/webapp2 ->webapp2
http://myServerIp2:8080/webapp3 ->webapp3
(partner1 - tomcatServer1)
http://partner1.myDomain.com/ ->webapp1(main)
http://partner1.myDomain.com/webapp2 ->webapp2
(partner2 - tomcatServer2)
http://partner2.myDomain.com/ ->webapp1(main)
http://partner2.myDomain.com/webapp2 ->webapp2
http://partner2.myDomain.com/webapp3 ->webapp3
(partner1 - tomcatServer1)
http://myServerIp1:8080/ ->tomcat index
http://partner1.myDomain.com/ ->tomcat index
server {
listen 80 default_server;
listen [::]:80 default_server;
index index.html index.htm index.nginx-debian.html;
server_name partner1.myDomain.com;
location / {
proxy_pass http://myServerIp1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
try_files $uri $uri/ =404;
}
}
version: "3"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
restart: always
ports:
- '80:80'
- '443:443'
volumes:
- '/var/run/docker.sock:/tmp/docker.sock:ro'
- /etc/nginx/vhost.d
- /usr/share/nginx/html
- /etc/nginx/dhparam
- /etc/nginx/certs
- ./my-custom-config.conf:/etc/nginx/conf.d/my-custom-config.conf:ro
letsencrypt:
restart: always
container_name: letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion:v1.13
volumes_from:
- nginx-proxy
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:ro'
server1:
container_name: server1
image: tomcat:8-jdk8
volumes:
- webs/web1.war:/usr/local/tomcat/webapps/ROOT.war
environment:
VIRTUAL_HOST: server1.example.com
LETSENCRYPT_HOST: server1.example.com
server2:
container_name: server1
image: tomcat:8-jdk8
volumes:
- webs/web2.war:/usr/local/tomcat/webapps/ROOT.war
environment:
VIRTUAL_HOST: server2.example.com
LETSENCRYPT_HOST: server2.example.com
server3:
container_name: server1
image: tomcat:8-jdk8
volumes:
- webs/web3.war:/usr/local/tomcat/webapps/ROOT.war
environment:
VIRTUAL_HOST: server3.example.com
LETSENCRYPT_HOST: server3.example.com
1985a escribió:Mira esta pagina, quizas te ayude a generar un archivo de configuracion para tu caso
https://www.digitalocean.com/community/tools/nginx
Aplicación servida por tomcat a través de la ip de forma directa:nada mas entrar crea un JSESSIONID(o similar)
Si recargas la página, ese JSESSIONID se mantiene
Te logueas y lo pasa como cookie al navegador
Aplicación servida por nginxt a través del dominio:nada mas entrar crea un JSESSIONID(o similar)
Si recargas la página, ese JSESSIONID se renueva
Te logueas y NO lo pasa como cookie al navegador, así que no te valida el primer modulo que carga y peta.
en ocasiones, ese JSESSIONID, se renueva incluso pasando el login, por lo que sigues estando sin validar.
proxy_set_header Cookie $http_cookie;
miguej escribió:No se como tienes la configuración ahora que te funciona pero igual te falta elproxy_set_header Cookie $http_cookie;
en la config del nginx.
---------------
-----nginx.conf
---------------
user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;
events {
multi_accept on;
worker_connections 65535;
}
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
client_max_body_size 16M;
# MIME
include mime.types;
default_type application/octet-stream;
# Logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
# Load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
---------------
-----General
---------------
# favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
}
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
---------------
-----Proxy
---------------
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
# Proxy headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
---------------
-----webapp
---------------
server {
listen 80;
listen [::]:80;
server_name sub.dominio.etc;
# logging
access_log /var/log/nginx/sub.dominio.etc.access.log;
error_log /var/log/nginx/sub.dominio.etc.error.log warn;
# reverse proxy
location / {
proxy_pass http://xx.xx.xx.xx:yyyy/webapp/;
include nginxconfig.io/proxy.conf;
}
# additional config
include nginxconfig.io/general.conf;
}
proxy_cookie_path ~*^/.* /;