Context path and Piccaport behind NGINX reverse proxy | PicApport.Version=V8.2.2 14.02.2020

465 views
Skip to first unread message

José Benlloch

unread,
Feb 27, 2020, 3:47:31 PM2/27/20
to PicApport
PicApport.Version=V8.2.2 14.02.2020 | nginx version: nginx/1.17.8 | java.version: 11.0.6  openj9-0.18.1  Eclipse OpenJ9 VM

I want to set the context path according to the server guide in order to serve picapport behind nginx.

Having: -Dserver.contextPath=/terminator

or even 

-Dserver.servlet.contextPath=/medium   (for Spring Boot 2.0.0)

or even both of them inside the java start script ...

java -Xms512m -Xmx2048m -Dstorage.diskCache.bufferSize=256 -DTRACE=DEBUG -Dserver.contextPath=/medium
 -Duser.home=/media/sda/picapport -jar /media/sda/picapport/picapport-headless.jar

Doesn't produces the expected results like:

Wird nun der server.contextpath gesetzt ändert sich dies wie folgt:

server.contextpath=/medium

2020-02-27_20h41_45.png


2020-02-27_20h39_40.png


2020-02-27_20h43_17.png



Why the context path is not being respected (either /medium nor /terminator)? Are here my assumptions right?  It just works with /picapport!? 

I can observe on the logfiles only the following entries with "terminator" or "medium"

$ grep -i "terminator\|medium" /media/sda/picapport/.picapport/logfiles/picapport.004
MSG  
@ 20:07:21.883 java.runtime.argument: -Dserver.servlet.contextPath=/medium
MSG  @ 20:07:21.883 java.runtime.argument: -Dserver.contextPath=/
terminator
DEBUG@
20:07:21.962 PicApportRestartHandler.init: vmargs[12]=-Dserver.servlet.contextPath=/medium
DEBUG@ 20:07:21.962 PicApportRestartHandler.init: vmargs[13]=-Dserver.contextPath=/
terminator


in NGINX the block according the suggestion from Andreas Herstermeyer returns a 502 error:

location ~ ^/medium(.*)$ {
        set $query $1; # https:/
/stackoverflow.com/questions/8838905/how-to-avoid-nginx-to-replace-20-by-whitespace-when-using-as-a-proxy-proxy-pas
        proxy_http_version
1.1;
        proxy_pass http
://192.168.178.90/medium$query$is_args$args;
        proxy_redirect http
://192.168.178.90/medium http://$host/medium;
        proxy_set_header
Referer http://192.168.178.90:8080/medium/picapport;
        proxy_set_header
Host 192.168.178.90:8080;
        proxy_set_header
Connection "";
       
#proxy_set_header Accept-Encoding "gzip, deflate, br";
       
#proxy_set_header Connection "keep-alive";
        access_log
/var/log/nginx/picapport.log;
   
}

following other advices in internet like:

 
location ~ /notmedium/ {
        proxy_set_header
Authorization "Basic dXNlcm5hbWU6cGFzc3dvcnQ=";   #encode base64 user & pw are fakes here
        proxy_pass http
://192.168.178.90:8080/picapport$is_args$args;
        proxy_set_header X
-Forwarded-Host $host;
        proxy_set_header  
Host             $http_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-User $http_authorization;


        
produces

2020-02-27_21h23_57.png


 but still I'm not able to serve the images, css, js, etc. It looks like that the context path is not being considered:

http://192.168.178.90:8080/images/312x111_header.png
http://192.168.178.90:8080/images/picapport_logo_trans.png
http://192.168.178.90:8080/images/312x111_header.png
http://192.168.178.90:8080/lp?vid=1&index=0&cx=1920&cy=1080
http://192.168.178.90:8080/picapport_folder?rootid=CZJTQBL&folder=6KqPaag
http://192.168.178.90:8080/js/jquery.mobile-1.4.5.min.map

PicApport

unread,
Feb 28, 2020, 3:21:19 AM2/28/20
to PicApport
Hallo José,
the context path is set in picapport.properties and not with -D.
The parameter name is also case sensitive so it's server.contextpath and not server.contextPath
You can also provide the parameter on the command line with the -p argument (please see server guide link above)

José Benlloch

unread,
Feb 29, 2020, 6:42:22 AM2/29/20
to PicApport

Hallo Eric,

good catch!, Indeed I observed the case sensitive, but I was playing around with -D, instead of setting it in piccaport.properties.

Just to summarize how to enable context path, troubleshooting & nginx:


$ cat picapport.properties
server
.port=8080
...
...
server
.contextpath=/myalbum     # careful: even in other external guides they use other spelling like contextPath or context-path


Check Picapport Logfile:

$ grep -i myalbum /media/sda/picapport/.picapport/logfiles/picapport.00*
DEBUG@
12:07:23.414 GenProperties.getProperty: Key=server.contextpath value=/myalbum
INFO @ 12:07:23.442 PicApportServlet.initServletPathWithContext:/
myalbum/picapport     #<---- Works!
MSG  
@ 12:07:23.476 Init: server.contextpath=/myalbum


here is basically my working location block inside nginx reverse proxy for Picapport, since the one suggested by Andreas Hestermeyer, it doesn't work at my end:


    location /myalbum/ {
        proxy_pass http
://192.168.178.90:8080/myalbum/;

        http2_push_preload on
;         # disable it , if you don't use http2
        proxy_http_version
1.1;        # default proxy http version = 1.0



The trailing slashes are mandatory on location block and proxy_pass directive after myalbum

We just type in browser https://myserver.de/myalbum/picapport in order to reach picapport

2020-02-29_12h24_31.png


Thanks once again for the Picapport application, support, fixing & improving. Keep it the good work. MUCH appreciated :-)

Reply all
Reply to author
Forward
0 new messages