Voici ma configuration nginx :
server {
listen 80;
listen [::]:80;
server_name my-domain.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
#pass through headers from Jenkins which are considered invalid by Nginx server.
ignore_invalid_headers off;
location /userContent {
#have nginx handle all the static requests to the userContent folder files
#note : This is the $JENKINS_HOME dir
root /var/lib/jenkins/;
if (!-f $request_filename){
#this file does not exist, might be a directory or a /**view** url
rewrite (.*) /$1 last;
break;
}
sendfile on;
}
location / {
root /opt/tomcat/webapps/ROOT/;
#index index.jsp index.html index.htm;
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;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_pass http://127.0.0.1:7070/;
}
#Include other locations
include /etc/nginx/locations-enabled/*.loc;
}
et dans /etc/nginx/locations-enabled/flowable.loc
location /flowable-idm {
root /opt/tomcat/webapps/flowable-idm;
include /etc/nginx/mime.types;
access_log /var/log/nginx/flowable/access.log;
error_log /var/log/nginx/flowable/error.log;
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1M;
}
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;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_pass http://127.0.0.1:7070/flowable-idm;
}
L'installation est un proxy pour certaines applications déployées dans Apache Tomcat. Les permissions dans le répertoire racine sont les suivantes :
-rw-r----- 1 tomcat tomcat 3.5K Apr 5 2017 404.html
-rw-r----- 1 tomcat tomcat 250 Apr 5 2017 browserconfig.xml
-rw-r----- 1 tomcat tomcat 15K Apr 5 2017 favicon.ico
drwxr-x--- 2 tomcat tomcat 4.0K Dec 20 10:45 fonts/
-rw-r----- 1 tomcat tomcat 24K Apr 5 2017 .htaccess
drwxr-x--- 2 tomcat tomcat 4.0K Dec 20 10:45 i18n/
-rw-r----- 1 tomcat tomcat 8.1K Dec 22 13:54 idm-service.js
drwxr-x--- 2 tomcat tomcat 4.0K Dec 20 10:45 images/
-rw-r----- 1 tomcat tomcat 6.8K Dec 11 16:04 index.html
drwxr-x--- 34 tomcat tomcat 4.0K Dec 20 10:45 libs/
-rw-r----- 1 tomcat tomcat 318 Apr 5 2017 manifest.json
drwxr-x--- 3 tomcat tomcat 4.0K Dec 20 10:45 META-INF/
drwxr-x--- 3 tomcat tomcat 4.0K Dec 20 10:45 scripts/
drwxr-x--- 4 tomcat tomcat 4.0K Dec 20 10:45 styles/
drwxr-x--- 4 tomcat tomcat 4.0K Dec 20 10:45 views/
drwxr-x--- 4 tomcat tomcat 4.0K Dec 20 10:45 WEB-INF/
avec Nginx ajouté en tant que membre du groupe de travail tomcat groupe. Pour l'instant, Nginx est capable de servir les fichiers xml et HTML situés à la racine mais j'obtiens un 404 pour tout autre type de fichier qui devrait être servi.
Ainsi, alors que la page index.html est chargée, tous les autres fichiers (.css et .js) dans les sous-répertoires libs, scripts, styles et view renvoient 404s. Voici la sortie de nginx -V :
nginx version: nginx/1.13.7
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
EDIT : Voici les demandes que j'ai faites à des fins de test :
http://my-domain/flowable-idm/favicon.ico retourne 404
http://my-domain/flowable-idm/index.html retourne 200
http://my-domain/flowable-idm/404.html retourne 200
http://my-domain/flowable-idm/idm-services.js retourne 404
0 votes
Si je peux me permettre une supposition spontanée : il faudrait peut-être ajouter
try_files $uri $uri/ =404;
à l'intérieur dulocation ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
bloc.0 votes
@mjb2kmn Pas de chance. La situation reste inchangée.