You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "cfeltz34 (via GitHub)" <gi...@apache.org> on 2023/06/07 06:47:37 UTC

[GitHub] [couchdb] cfeltz34 opened a new issue, #4635: Bad redirection 301 from request on _design%2F with reverse proxy

cfeltz34 opened a new issue, #4635:
URL: https://github.com/apache/couchdb/issues/4635

   ## Description
   
   Bad redirection 301 from request on _design%2F with reverse proxy.
   
   ## Steps to Reproduce
   
   Use docker compose to create CouchDB and Traefik (reverse proxy) containers and configure CouchDB with a PathPrefix : 
   `      - "traefik.http.routers.couchdb.rule=Host(`mydomain.com`) && PathPrefix(`/couchdb`)"`
   
   Create database "example". 
   
   Execute request "https://webapihelper.groupe-isia.com/couchdb/example/_design%2Fexample"
   --> CouchDB server return redirection 301 to https://domain.com/example/_design/example
   
   ## Expected Behaviour
   
   --> CouchDB server return redirection 301 to https://domain.com/couchdb/example/_design/example
   
   ## Data
   
   Full example for docker-compose with this file : 
   ```
   version: '3.7'
   
   services:
     traefik:
       container_name: example.traefik
       image: traefik:v2.6.0
       command:
         - "--log.level=DEBUG"
         - "--api.insecure=true"
         - "--providers.docker=true"
         - "--providers.docker.exposedbydefault=false"
       ports:
         - "80:80"
         - "443:443"
         - "8080:8080"
       volumes:
         - "/var/run/docker.sock:/var/run/docker.sock:ro"
         - "./Traefik/traefik.toml:/etc/traefik/traefik.toml"
         - "./Traefik/configuration/:/configuration/"
         - "../../Certificates/:/certificates/"
       networks:
         - network
   
     couchdb:
       container_name: example.couchdb
       image: couchdb:3.3.1
       environment:
         - COUCHDB_USER=xxx
         - COUCHDB_PASSWORD=xxx
       volumes:
         - couchdb-data:/opt/couchdb/data
       labels:
         - "traefik.enable=true"
         - "traefik.http.services.couchdb.loadbalancer.server.port=5984"
         # - "traefik.http.routers.couchdb.rule=Host(`couchdb.mydomain.com`)"
         - "traefik.http.routers.couchdb.rule=Host(`mydomain.com`) && PathPrefix(`/couchdb`)"
         - "traefik.http.middlewares.couchdb.stripprefix.prefixes=/couchdb"
         - "traefik.http.middlewares.couchdb.stripprefix.forceSlash=false"
         - "traefik.http.routers.couchdb.middlewares=couchdb@docker"
         - "traefik.http.routers.couchdb.entrypoints=web-secure"
         - "traefik.http.routers.couchdb.tls=true"
       networks:
         - network
             
   volumes:  
     couchdb-data:
   
   networks:
     network:
   
   ```
   
   ## Your Environment
   
   {"couchdb":"Welcome","version":"3.3.1","git_sha":"1fd50b82a","uuid":"380d7087e65adca8a7336c699bc5c564","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
   
   * CouchDB version used: 3.3.1
   * Browser name and version: Chrome from Windows
   * Operating system and version: Debian Linux with docker and docker compose
   
   ## Additional Context
   
   I'm not sure, but in file "couch_httpd_db.erl" (on main branch) there are (line 517) : 
   ```
   db_req(
       #httpd{
           method = 'GET', mochi_req = MochiReq, path_parts = [DbName, <<"_design/", _/binary>> | _]
       } = Req,
       _Db
   ) ->
       **PathFront = "/" ++ couch_httpd:quote(binary_to_list(DbName)) ++ "/",**
       [_ | PathTail] = re:split(
           MochiReq:get(raw_path),
           "_design%2F",
           [{return, list}]
       ),
       couch_httpd:send_redirect(
           Req,
           PathFront ++ "_design/" ++
               mochiweb_util:join(PathTail, "_design%2F")
       );
   
   ```
   --> PathFront need to use the path prefix (may by add environment variable to set full url (like KC_HOSTNAME_URL for Keycloak).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] rnewson commented on issue #4635: Bad redirection 301 from request on _design%2F with reverse proxy

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on issue #4635:
URL: https://github.com/apache/couchdb/issues/4635#issuecomment-1618537625

   Not a bug.
   
   CouchDB expects to own the full url path and does not support a prefix. Replication will fail, etc.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [couchdb] rnewson closed issue #4635: Bad redirection 301 from request on _design%2F with reverse proxy

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson closed issue #4635: Bad redirection 301 from request on _design%2F with reverse proxy
URL: https://github.com/apache/couchdb/issues/4635


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org