Skip to content

Invalid port in upstream #287

@Tesfa1074

Description

@Tesfa1074

Describe the bug
I am having the following issue using the relay proxy after configuration.

Error

10 October 2024 at 10:48 (UTC+2:00) | 2024/10/10 08:48:50 [error] 37#37: *209 invalid port in upstream "https://manager.us.smartlook.cloud", client: 10.100.22.225, server: , request: "POST /manager/rec/setup-recording/website HTTP/1.1", host: "<proxy-host>:8585", referrer: "https://<custom-domain>/" | a22c36a3aa8442f78f5e329affacefcd | worker
-- | -- | -- | --
10 October 2024 at 10:48 (UTC+2:00) | 10.100.22.225 - - [10/Oct/2024:08:48:50 +0000] "POST /manager/rec/setup-recording/website HTTP/1.1" 500 572 "<custom-domain>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"

10 October 2024 at 10:48 (UTC+2:00)
2024/10/10 08:48:50 [error] 37#37: *209 invalid port in upstream "https://manager.us.smartlook.cloud", client: 10.100.22.225, server: , request: "POST /manager/rec/setup-recording/website HTTP/1.1", host: "<proxy-host>:8585", referrer: "<custom-domain>"

10 October 2024 at 10:48 (UTC+2:00)
10.100.22.225 - - [10/Oct/2024:08:48:50 +0000] "POST /manager/rec/setup-recording/website HTTP/1.1" 500 572 "<custom-domain>" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"

Proxy is running on AWS ECS.

To Reproduce
Docker config for my ECS

FROM nginx:1-alpine

ARG COMMIT_SHA="unknown"

COPY ./nginx/templates /etc/nginx/templates
COPY --chmod=0555 ./nginx/entrypoint.sh /docker-entrypoint.d/40-smartlook-relay-proxy.sh

ENV COMMIT_SHA=${COMMIT_SHA}
ENV PROXY_PORT=8000
ENV CLIENT_MAX_BODY_SIZE=20m
ENV ERROR_LOG_LEVEL=error
ENV WEB_SDK_HOST=web-sdk.smartlook.com
ENV MANAGER_HOST=manager.us.smartlook.cloud
ENV ASSETS_PROXY_HOST=assets-proxy.smartlook.cloud
ENV WEB_SDK_WRITER_HOST=web-writer.us.smartlook.cloud
ENV MOBILE_SDK_WRITER_HOST=sdk-writer.us.smartlook.cloud

EXPOSE ${PROXY_PORT}

NGINX Config

map $status $loggable {
    ~^[23]  0;
    default 1;
}

server {
    listen ${PROXY_PORT};
    
    proxy_cache off;
    proxy_ssl_server_name on;
    proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    server_tokens off;
    client_max_body_size ${CLIENT_MAX_BODY_SIZE};

    error_log /dev/stderr ${ERROR_LOG_LEVEL};
    access_log /dev/stdout combined if=$loggable;

    location /proxy/status {
        default_type application/json;

        return 200 '{ "app": "smartlook-relay-proxy", "version": "${COMMIT_SHA}" }';
    }

    set $manager_host ${MANAGER_HOST};
    set $assets_proxy_host ${ASSETS_PROXY_HOST};
    set $web_sdk_writer_host ${WEB_SDK_WRITER_HOST};
    set $mobile_sdk_writer_host ${MOBILE_SDK_WRITER_HOST};
    set $web_sdk_host ${WEB_SDK_HOST};

    proxy_pass_header Server;

    resolver 1.1.1.1 1.0.0.1 valid=5m;

    location /manager/ {
        rewrite ^/manager(/.*)$ $1 break;
        proxy_pass https://$manager_host;

        proxy_set_header Host $manager_host;
        proxy_set_header X-Forwarded-Host $manager_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-Proto $scheme;
        proxy_set_header X-Forwarded-By smartlook-relay-proxy;
    }

    location /assets/ {
        rewrite ^/assets(/.*)$ $1 break;
        proxy_pass https://$assets_proxy_host;

        proxy_set_header Host $assets_proxy_host;
        proxy_set_header X-Forwarded-Host $assets_proxy_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-Proto $scheme;
        proxy_set_header X-Forwarded-By smartlook-relay-proxy;
    }

    location /web-writer/ {
        rewrite ^/web-writer(/.*)$ $1 break;
        proxy_pass https://$web_sdk_writer_host;

        proxy_set_header Host $web_sdk_writer_host;
        proxy_set_header X-Forwarded-Host $web_sdk_writer_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-Proto $scheme;
        proxy_set_header X-Forwarded-By smartlook-relay-proxy;
    }

    location /sdk-writer/ {
        rewrite ^/sdk-writer(/.*)$ $1 break;
        proxy_pass https://$mobile_sdk_writer_host;

        proxy_set_header Host $mobile_sdk_writer_host;
        proxy_set_header X-Forwarded-Host $mobile_sdk_writer_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-Proto $scheme;
        proxy_set_header X-Forwarded-By smartlook-relay-proxy;
    }

    location / {
        proxy_pass https://$web_sdk_host;

        proxy_set_header Host $web_sdk_host;
        proxy_set_header X-Forwarded-Host $web_sdk_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-Proto $scheme;
        proxy_set_header X-Forwarded-By smartlook-relay-proxy;
    }
}

Desktop (please complete the following information):

  • OS: Any
  • Browser: Chrome
  • Version: Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions