Comments (7)
Thanks for the question! I'm a bit hestitant to add this feature for two reasons:
- You can change the context path today if you specify a custom jetty configuration file using the
JETTY_CONFIG_PATH
environment variable. Of course, then you're in charge of maintaining that file. - It seems like this would be better handled by having the upstream proxy rewrite the HTTP request path anyway.
I'll explain my thinkign on 2 a bit more. If archiva is hosted under a path-based root of some common fqdn, it seems like that configuration should be "owned" by the proxy that routes requests for that fqdn. I don't believe the archiva environment needs to even know about it.
For all the common HTTP proxies (HAProxy, Nginx, apache) path re-writing to the backend should be pretty simple. For HAproxy, you can use the set-path
directive, for Nginx use rewrite
and for apache use mod_rewrite
.
Is there a reason 2 wouldn't work for you?
from docker-archiva.
Just a quick friendly nudge. If I don't hear back from by this weekend, I'm going to close out this issue.
from docker-archiva.
Hi, thanks for your answer, I'll opt for the reverse proxy re-writing the request.
It works perfectly.
Sorry for the delay, I was on holiday.
Have a nice day
Adrien
from docker-archiva.
Hello again,
in fact, it's not working as expected.
Following is my stack deploy file. Archiva is available on https://example.org/archiva/ but if you remove the trailing slash, archiva is still accessible, but the assets are not loading properly making it buggy.
`# docker stack deploy -c archiva.yml archiva
version: '3.3'
services:
archiva:
image: xetusoss/archiva:latest
volumes:
- 'archiva-data:/archiva-data'
environment:
PROXY_BASE_URL: https://example.org/archiva/
networks:
- default
- proxy
deploy:
labels:
- com.df.notify=true
- com.df.servicePath=/archiva
- com.df.port=8080
- com.df.xForwardedProto=true
- com.df.reqPathSearch=/archiva/
- com.df.reqPathReplace=/
networks:
default:
external: false
proxy:
external: true
volumes:
archiva-data:
`
So, I looked at how you docker image works, and did a few modifications.
I think it would be great to add support for custom context path on your image.
It's as simple as:
Adding a new environment variable in your Dockerfile:
ENV CONTEXT_PATH /
And then, in your entrypoint.sh, add the following line:
sed -i 's:<Set name="contextPath">/</Set>:<Set name="contextPath">'"$CONTEXT_PATH"'</Set>:' /archiva/contexts/archiva.xml
Thanks for your consideration,
Adrien
from docker-archiva.
Sorry to be slow getting back to you!
Archiva uses relative paths for all its assets. This is good, but results in the behavior your describing since your browser will try to retrieve those assets without the context path (e.g. from /
instead of /archiva/
) when you try to access Archiva without the trailing slash (e.g. /archiva
vs. /archiva/
).
Note that these relative paths are hardcoded in Archiva's index.html. This means that configuring the context path with the Archiva servlet still won't resolve the behavior you encountered, since this behavior is caused by the browser issuing requests for assets relative to the root path rather than context path. Your reverse proxy will never route those requests to the Archiva server, so they'll always error out.
This is a common scenario that comes up when separating services via reverse-proxy-managed context paths that should be handled by the reverse proxy configuration, most typically by redirecting requests to add the trailing slash (e.g. https://example.org/archiva
=> https://example.org/archiva/
).
Redirecting to Trailing Slash with Docker Flow Proxy (HaProxy)
It looks like you're using Docker Flow Proxy, which is really just an HaProxy orchestrator. While Docker Flow Proxy's default HaProxy frontend configuration doesn't enforce trailing slashes, it looks like you have at least two options for adding custom rules to do this:
-
Using the EXTRA_FRONTEND environment variable in your
dockerflow/docker-flow-proxy
docker containers; -
Adding your end frontend template to your
dockerflow/docker-flow-proxy
docker containers.
This docker-flow-proxy issue details exactly the same scenario, and one of the comments shows how to set this up using the EXTRA_FRONTEND
environment variable on the docker-flow-proxy
container.
I was able to get this working in a local docker swarm using the following docker-flow-proxy
stack definition:
version: "3"
services:
proxy:
image: dockerflow/docker-flow-proxy
ports:
- 80:80
- 443:443
networks:
- proxy
environment:
- LISTENER_ADDRESS=swarm-listener
- MODE=swarm
- EXTRA_FRONTEND=acl is_root path -i /,acl missing_slash path_reg ^/*/[^/]*$$,http-request redirect code 301 prefix / append-slash if missing_slash !is_root
deploy:
replicas: 2
swarm-listener:
image: dockerflow/docker-flow-swarm-listener
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DF_NOTIFY_CREATE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/reconfigure
- DF_NOTIFY_REMOVE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/remove
deploy:
placement:
constraints: [node.role == manager]
networks:
proxy:
external: true
Note the EXTRA_FRONTEND
environment variable value, which you may need to customize for your needs:
acl is_root path -i /,acl missing_slash path_reg ^/*/[^/]*$$,http-request redirect code 301 prefix / append-slash if missing_slash !is_root
Does that help?
from docker-archiva.
Hello,
yes it definitely helps.
Thanks for helping me resolving this issue and for the time you spent answering me.
Have a nice day
Adrien
from docker-archiva.
Glad to hear it @fahrenheit9! Best of luck to you!
from docker-archiva.
Related Issues (20)
- Running from example seems to hang on "Loading" HOT 2
- Artifacts are no longer stored under /archiva-data HOT 3
- What is the root password for Archiva Docker image? HOT 1
- while trying to push the artifact from jenkins(CI Job) to nexus.Error:"HTTP method PUT is not supported by this URL". HOT 1
- Latest openjdk:8 image breaks builds due to cacerts being moved.
- Error creating bean with name 'authenticationInterceptor#rest' HOT 2
- Hello, I'm new to docker. How easy would it be to add the $PORT env variable as a configuration parameter ? Thanks HOT 1
- validation_mail: user and password set via env variable HOT 2
- Container does not start as expected (HTTP ERROR 404) HOT 2
- How to set rest.baseUrl if behind proxy. HOT 2
- can't create directory '/archiva-data/data': Permission denied HOT 6
- Increase upload size HOT 9
- Add support for ARM 64 HOT 2
- Critical Log4j RCE bug (CVE-2021-44228) HOT 2
- Dockerhub tag `latest` does not seem to get updated HOT 1
- SSL Connection issue while connecting to mysql database HOT 1
- Write migration guide to reposilite
- Archiva 2.2.10 HOT 1
- Adding port 8443 to port list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-archiva.