Problema de CORS en Alfresco 7.0

cancel
Showing results for 
Search instead for 
Did you mean: 
mmbadaracco
Active Member

Problema de CORS en Alfresco 7.0

Hola a todos/as, he realizado una instalación de Alfresco con docker-compose. Mi problema de cors surge al momento de realizar peticiones a la API Rest desde otro origen, intenté agregar configuraciones al archivo docker-compose.yml para habilitarlo, pero no han surtido efecto. ¿Podrían indicarme detalladamente cómo puedo habilitar de forma correcta un origen cruzado?

Muchas gracias desde ya.

4 Replies
cristinamr
Advanced

Re: Problema de CORS en Alfresco 7.0

Buenas.

No deberías tener problema a la hora de realizar peticiones REST. ¿Podrías facilitarnos el error que te da en el log así como archivos de configuración (docker-compose.yml)?

Un saludo.

--
VenziaIT: helping companies since 2005! Our ECM products: AQuA & Seidoc
mmbadaracco
Active Member

Re: Problema de CORS en Alfresco 7.0

Muchas gracias por su tiempo. Adjunto la configuración del archivo yml y seguidamente la respuesta en consola al intentar realizar un petición GET.

 

# Using version 2 as 3 does not support resource constraint options (cpu_*, mem_* limits) for non swarm mode in Compose
version"2"

services:
    alfresco:
        build:
          context./alfresco
          args:
            ALFRESCO_TAG${ALFRESCO_CE_TAG}
            DBpostgres
            API_EXPLORER_TAG${API_EXPLORER_TAG}
        mem_limit4416m
        depends_on
            - postgres  
        environment:
            JAVA_TOOL_OPTIONS"
                -Dencryption.keystore.type=JCEKS
                -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
                -Dencryption.keyAlgorithm=DESede
                -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
                -Dmetadata-keystore.password=mp6yc0UD9e
                -Dmetadata-keystore.aliases=metadata
                -Dmetadata-keystore.metadata.password=oKIWzVdEdA
                -Dmetadata-keystore.metadata.algorithm=DESede
                "
            JAVA_OPTS : "
                -Ddb.driver=org.postgresql.Driver
                -Ddb.username=alfresco
                -Ddb.password=alfresco
                -Ddb.driver=org.postgresql.Driver
                -Ddb.url=jdbcSmiley Tongueostgresql://postgres:5432/alfresco  
                -Dsolr.host=solr6
                -Dsolr.port=8983
                -Dsolr.secureComms=none
                -Dsolr.baseUrl=/solr
                -Dindex.subsystem.name=solr6
                -Dalfresco.host=${SERVER_NAME}
                -Dalfresco.port=80
                -Dalfresco.protocol=http 
                -Dshare.host=${SERVER_NAME}
                -Dshare.port=80
                -Dshare.protocol=http 
                -Daos.baseUrlOverwrite=http://${SERVER_NAME}/alfresco/aos
                -Dmessaging.broker.url=\"failoverSmiley Sadnio://activemq:61616)?timeout=3000&jms.useCompression=true\"
                -Ddeployment.method=DOCKER_COMPOSE
                -Dcsrf.filter.enabled=false 
                -Dopencmis.server.override=true
                -Dopencmis.server.value=http://${SERVER_NAME}:80
                -DlocalTransform.core-aio.url=http://transform-core-aio:8090/
                -Dcsrf.filter.enabled=false
                -Dalfresco.restApi.basicAuthScheme=true
                -Dauthentication.protection.enabled=false
                -XX:+UseG1GC -XX:+UseStringDeduplication
                -Dgoogledocs.enabled=true 
                -Xms3904m -Xmx3904m   
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
            "
        volumes
            - ./data/alf-repo-data:/usr/local/tomcat/alf_data
            - ./logs/alfresco:/usr/local/tomcat/logs   
        

    transform-core-aio:
        imagealfresco/alfresco-transform-core-aio:${TRANSFORM_ENGINE_TAG}
        mem_limit1536m
        environment:
            JAVA_OPTS" -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80"

    share:
        build:
          context./share
          args:
            SHARE_TAG${SHARE_TAG}
            SERVER_NAME${SERVER_NAME}
        mem_limit1104m
        environment:
            REPO_HOST"alfresco"
            REPO_PORT"8080"
            CSRF_FILTER_REFERER"http://localhost/.*"
            CSRF_FILTER_ORIGIN"http://localhost"
            JAVA_OPTS"
                -Xms976m -Xmx976m
                -Dalfresco.context=alfresco
                -Dalfresco.protocol=http
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
                "
        volumes
            - ./logs/share:/usr/local/tomcat/logs  

    
    postgres:
        imagepostgres:${POSTGRES_TAG}
        mem_limit1104m
        environment:
            - POSTGRES_PASSWORD=alfresco
            - POSTGRES_USER=alfresco
            - POSTGRES_DB=alfresco
        command"
            postgres
              -c max_connections=200
              -c logging_collector=on
              -c log_min_messages=LOG
              -c log_directory=/var/log/postgresql"
        ports:
            - 5432:5432
        volumes
            - ./data/postgres-data:/var/lib/postgresql/data
            - ./logs/postgres:/var/log/postgresql  
     

    solr6:
        build:
          context./search
          args:
            SEARCH_TAG$SEARCH_CE_TAG
            SOLR_HOSTNAMEsolr6
            ALFRESCO_HOSTNAMEalfresco
            ALFRESCO_COMMSnone
            CROSS_LOCALE"true"
        mem_limit2208m
        environment:
            #Solr needs to know how to register itself with Alfresco
            SOLR_ALFRESCO_HOST"alfresco"
            SOLR_ALFRESCO_PORT"8080"
            #Alfresco needs to know how to call solr
            SOLR_SOLR_HOST"solr6"
            SOLR_SOLR_PORT"8983"
            #Create the default alfresco and archive cores
            SOLR_CREATE_ALFRESCO_DEFAULTS"alfresco,archive"
            SOLR_JAVA_MEM"-Xms1952m -Xmx1952m"
            SOLR_OPTS"
                -XX:NewSize=848m
                -XX:MaxNewSize=848m
            "
        volumes
            - ./data/solr-data:/opt/alfresco-search-services/data  

    activemq:
        imagealfresco/alfresco-activemq:${ACTIVEMQ_TAG}
        mem_limit1g
        ports:
            - 8161:8161 # Web Console
            - 5672:5672 # AMQP
            - 61616:61616 # OpenWire
            - 61613:61613 # STOMP

    content-app:
        imagealfresco/alfresco-content-app:${ACA_TAG}
        mem_limit256m
        depends_on:
            - alfresco
            - share

    # HTTP proxy to provide HTTP Default port access to services
    # SOLR API and SOLR Web Console are protected to avoid unauthenticated access
    proxy:
        imageangelborroy/acs-proxy:1.2.0
        mem_limit128m
        environment:
            - PORT=80
        depends_on:
            - alfresco
            - solr6
            - share
            - content-app
        volumes:
            - ./config/nginx.htpasswd:/etc/nginx/conf.d/nginx.htpasswd 
        ports:
            - 80:80

    
 

Utilicé la extensión de visual studio code liveserver para correr la aplicación que realiza las peticiones:

error-fetch-alfresco.PNG

mmbadaracco
Active Member

Re: Problema de CORS en Alfresco 7.0

Buenos días, gracias por su tiempo. Adjunto la configuración del archivo docker-compose.yml y seguidamente, la respuesta en consola del navegador al realizar una petición GET.

 

# Using version 2 as 3 does not support resource constraint options (cpu_*, mem_* limits) for non swarm mode in Compose
version: "2"

services:
    alfresco:
        build:
          context: ./alfresco
          args:
            ALFRESCO_TAG: ${ALFRESCO_CE_TAG}
            DB: postgres
            API_EXPLORER_TAG: ${API_EXPLORER_TAG}
        mem_limit: 4416m
        depends_on: 
            - postgres  
        environment:
            JAVA_TOOL_OPTIONS: "
                -Dencryption.keystore.type=JCEKS
                -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
                -Dencryption.keyAlgorithm=DESede
                -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
                -Dmetadata-keystore.password=mp6yc0UD9e
                -Dmetadata-keystore.aliases=metadata
                -Dmetadata-keystore.metadata.password=oKIWzVdEdA
                -Dmetadata-keystore.metadata.algorithm=DESede
                "
            JAVA_OPTS : "
                -Ddb.driver=org.postgresql.Driver
                -Ddb.username=alfresco
                -Ddb.password=alfresco
                -Ddb.driver=org.postgresql.Driver
                -Ddb.url=jdbc:postgresql://postgres:5432/alfresco  
                -Dsolr.host=solr6
                -Dsolr.port=8983
                -Dsolr.secureComms=none
                -Dsolr.baseUrl=/solr
                -Dindex.subsystem.name=solr6
                -Dalfresco.host=${SERVER_NAME}
                -Dalfresco.port=80
                -Dalfresco.protocol=http 
                -Dshare.host=${SERVER_NAME}
                -Dshare.port=80
                -Dshare.protocol=http 
                -Daos.baseUrlOverwrite=http://${SERVER_NAME}/alfresco/aos
                -Dmessaging.broker.url=\"failover:(nio://activemq:61616)?timeout=3000&jms.useCompression=true\"
                -Ddeployment.method=DOCKER_COMPOSE
                -Dcsrf.filter.enabled=false 
                -Dopencmis.server.override=true
                -Dopencmis.server.value=http://${SERVER_NAME}:80
                -DlocalTransform.core-aio.url=http://transform-core-aio:8090/
                -Dcsrf.filter.enabled=false
                -Dalfresco.restApi.basicAuthScheme=true
                -Dauthentication.protection.enabled=false
                -XX:+UseG1GC -XX:+UseStringDeduplication
                -Dgoogledocs.enabled=true 
                -Xms3904m -Xmx3904m   
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
            "
        volumes: 
            - ./data/alf-repo-data:/usr/local/tomcat/alf_data
            - ./logs/alfresco:/usr/local/tomcat/logs   
        

    transform-core-aio:
        image: alfresco/alfresco-transform-core-aio:${TRANSFORM_ENGINE_TAG}
        mem_limit: 1536m
        environment:
            JAVA_OPTS: " -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80"

    share:
        build:
          context: ./share
          args:
            SHARE_TAG: ${SHARE_TAG}
            SERVER_NAME: ${SERVER_NAME}
        mem_limit: 1104m
        environment:
            REPO_HOST: "alfresco"
            REPO_PORT: "8080"
            CSRF_FILTER_REFERER: "http://localhost/.*"
            CSRF_FILTER_ORIGIN: "http://localhost"
            JAVA_OPTS: "
                -Xms976m -Xmx976m
                -Dalfresco.context=alfresco
                -Dalfresco.protocol=http
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
                "
        volumes: 
            - ./logs/share:/usr/local/tomcat/logs  

    
    postgres:
        image: postgres:${POSTGRES_TAG}
        mem_limit: 1104m
        environment:
            - POSTGRES_PASSWORD=alfresco
            - POSTGRES_USER=alfresco
            - POSTGRES_DB=alfresco
        command: "
            postgres
              -c max_connections=200
              -c logging_collector=on
              -c log_min_messages=LOG
              -c log_directory=/var/log/postgresql"
        ports:
            - 5432:5432
        volumes: 
            - ./data/postgres-data:/var/lib/postgresql/data
            - ./logs/postgres:/var/log/postgresql  
     

    solr6:
        build:
          context: ./search
          args:
            SEARCH_TAG: $SEARCH_CE_TAG
            SOLR_HOSTNAME: solr6
            ALFRESCO_HOSTNAME: alfresco
            ALFRESCO_COMMS: none
            CROSS_LOCALE: "true"
        mem_limit: 2208m
        environment:
            #Solr needs to know how to register itself with Alfresco
            SOLR_ALFRESCO_HOST: "alfresco"
            SOLR_ALFRESCO_PORT: "8080"
            #Alfresco needs to know how to call solr
            SOLR_SOLR_HOST: "solr6"
            SOLR_SOLR_PORT: "8983"
            #Create the default alfresco and archive cores
            SOLR_CREATE_ALFRESCO_DEFAULTS: "alfresco,archive"
            SOLR_JAVA_MEM: "-Xms1952m -Xmx1952m"
            SOLR_OPTS: "
                -XX:NewSize=848m
                -XX:MaxNewSize=848m
            "
        volumes: 
            - ./data/solr-data:/opt/alfresco-search-services/data  

    activemq:
        image: alfresco/alfresco-activemq:${ACTIVEMQ_TAG}
        mem_limit: 1g
        ports:
            - 8161:8161 # Web Console
            - 5672:5672 # AMQP
            - 61616:61616 # OpenWire
            - 61613:61613 # STOMP

    content-app:
        image: alfresco/alfresco-content-app:${ACA_TAG}
        mem_limit: 256m
        depends_on:
            - alfresco
            - share

    # HTTP proxy to provide HTTP Default port access to services
    # SOLR API and SOLR Web Console are protected to avoid unauthenticated access
    proxy:
        image: angelborroy/acs-proxy:1.2.0
        mem_limit: 128m
        environment:
            - PORT=80
        depends_on:
            - alfresco
            - solr6
            - share
            - content-app
        volumes:
            - ./config/nginx.htpasswd:/etc/nginx/conf.d/nginx.htpasswd 
        ports:
            - 80:80

Aplicación corriendo con la extensión liveserver de visualstudio code:

error-fetch-alfresco.PNG

ricardodelgado
Member II

Re: Problema de CORS en Alfresco 7.0

Hi, were you able to find a solution?