I have a strange problem with a web application running in Tomcat as a deployable.
The html that user gets when finally being on https://my-url.com/admin tried to fetch multiple resources from the application deployed to Tomcat.
Now if the FIRST request to Tomcat is made via Nginx, one of the Javascript files fetched will have a
<html><head><title>301 Moved Permanently</title></head><body bgcolor="white"><center><h1>301 Moved Permanently</h1></center><hr><center>nginx/1.12.2</center></body></html>;
appended at the very end of the file. This breaks the whole page as we are quite reliant on Javascript. But if I would now restart Tomcat and make the first request straight against the application without going though Nginx, this line will not be appended. All requests afterwards will work as intended even though Nginx.
Here is the nginx conf:
user nginx nginx;
worker_processes 2;
pid /var/run/nginx.pid;
worker_rlimit_nofile 1024;
events {
worker_connections 512;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile "on";
client_max_body_size 20m;
client_body_timeout 300s;
client_body_in_file_only clean;
client_body_buffer_size 16K;
client_body_temp_path /tmp/client_body_temp;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
keepalive_timeout 65;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/name.crt;
ssl_certificate_key /etc/ssl/private/name.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers on;
server_name my-url.com;
location / {
return 301 https://$host/admin$request_uri;
}
location /admin {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass http://127.0.0.1:8080/admin/;
proxy_redirect http://127.0.0.1:8080/admin/ /admin/;
}
}
server {
listen 80;
server_name my-url.com;
access_log /dev/null;
return 301 https://$host$request_uri;
}
Would anyone have some idea on what is going on here that causes such issue?