0

ZK Spring boot behind a proxy ( NGINX )

asked 2020-07-24 16:34:20 +0800

typik gravatar image typik
3 1

I created zk application using zk spring boot starter. Everything works correctly.

SpringBootApplication.java:

@SpringBootApplication
@Controller
public class SpringBootApplication {
    @GetMapping("${application.base-path:}/{page}")
    public String view(@PathVariable String page) {
        return page;
    }

    public static void main(String[] args) {
        SpringApplication.run(SpringBootBesGuiApplication.class, args);
    }
}

project's structure:

.....................
src/main/resources
 |
  -- web
      js
        - script1.js
        - script2.js
      - page1.zul
      - page2.zul
.....................

page1.zul:

...................
<?script src="~./js/script1.js"?>
...................

http://my-server:8081/page1 is displaying correctly.

And after that I tried to run it behind a proxy ( nginx ). And the page is displaying nothing. There are errors in a browser console:

GET http://my-server/zkau/web/162740bd/_zkiju-sapphire/zul/css/zk.wcs net::ERR_ABORTED 502 (Bad Gateway)    
........................................................................................
GET http://my-server/zkau/web/162740bd/js/script1.js net::ERR_ABORTED 502 (Bad Gateway)
........................................................................................

It seems that there are wrong url's generated for *.wcs, *.wpd and my *.js files. What am I doing wrong? How can I repair it?

nginx.conf:

server {
listen 80;
server_name my-server;

........................................

location / {
proxy_pass http://my-server:8080;
fastcgi_read_timeout 300;
}

location /app {
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_pass http://my-server:8081;
fastcgi_read_timeout 300;
}
.............................................
}

application.properties:

application.base-path=/app
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-27 09:15:31 +0800

jeanher gravatar image jeanher
1789 2 6
ZK Team

The same question has been discussed and resolved in this thread in stackoverflow.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2020-07-24 16:34:20 +0800

Seen: 6 times

Last updated: Jul 27

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More