Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with port Proxy #8388

Closed
ekawibisono opened this issue Sep 4, 2023 · 6 comments
Closed

Problem with port Proxy #8388

ekawibisono opened this issue Sep 4, 2023 · 6 comments
Labels
waiting on feedback Waiting for original opener to respond if bug is fixed

Comments

@ekawibisono
Copy link

hello, please help, when I change proxy default.conf.template setting on listen 80 to 7121 why doesn't the API respond?

Environment

  • Deployment type (Manual/Docker/Docker-compose):docker-compose
  • Elixir & Erlang/OTP versions (elixir -version):
  • Node JS version (node -v):
  • Operating System: Ubuntu 20.04
  • Blockscout Version/branch/commit: Latest
  • Archive node type && version (Erigon/Geth/Nethermind/Ganache/?): Geth

Steps to reproduce

I tried to use port listen 80 API it works fine but when composing listen port 7121 api is not responding

Expected behaviour

I ask for help to solve this problem

image

This Config default.conf.template proxy

map $http_upgrade $connection_upgrade {

  default upgrade;
  ''      close;
}

server {
    listen       7121;
    server_name  localhost;
    proxy_http_version 1.1;

    location / {
        proxy_pass            http://ipaddress:4000;
        proxy_http_version    1.1;
        proxy_set_header      Host "$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      Upgrade "$http_upgrade";
        proxy_set_header      Connection $connection_upgrade;
        proxy_cache_bypass    $http_upgrade;
    }
    location = / {
        proxy_pass            http://ipaddress:3000;
        proxy_http_version    1.1;
        proxy_set_header      Host "$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      Upgrade "$http_upgrade";
        proxy_set_header      Connection $connection_upgrade;
        proxy_cache_bypass    $http_upgrade;
    }
    location ~ ^/(_next|node-api|apps|account|accounts|static|auth/profile|auth/unverified-email|txs|tx|blocks|block|login|address|stats|search-results|token|tokens|visualize|api-docs|csv-export|verified-contracts|graphiql|withdrawals) {
        proxy_pass            http://ipaddress:3000;
        proxy_http_version    1.1;
        proxy_set_header      Host "$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      Upgrade "$http_upgrade";
        proxy_set_header      Connection $connection_upgrade;
        proxy_cache_bypass    $http_upgrade;
    }
}
server {
    listen       8080;
    server_name  localhost;
    proxy_http_version 1.1;
    proxy_hide_header Access-Control-Allow-Origin;
    proxy_hide_header Access-Control-Allow-Methods;
    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Credentials' 'true' always;
    add_header 'Access-Control-Allow-Methods' 'PUT, GET, POST, OPTIONS, DELETE, PATCH' always;

    location / {
        proxy_pass            http://ipaddress:8153/;
        proxy_http_version    1.1;
        proxy_set_header      Host "$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      Upgrade "$http_upgrade";
        proxy_set_header      Connection $connection_upgrade;
        proxy_cache_bypass    $http_upgrade;
    }
}
server {
    listen       8081;
    server_name  localhost;
    proxy_http_version 1.1;
    proxy_hide_header Access-Control-Allow-Origin;
    proxy_hide_header Access-Control-Allow-Methods;
    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Credentials' 'true' always;
    add_header 'Access-Control-Allow-Methods' 'PUT, GET, POST, OPTIONS, DELETE, PATCH' always;
    add_header 'Access-Control-Allow-Headers' 'DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-csrf-token' always;

    location / {
        proxy_pass            http://ipaddress:8152/;
        proxy_http_version    1.1;
        proxy_buffering       off;
        proxy_set_header      Host "$host";
        proxy_set_header      X-Real-IP "$remote_addr";
        proxy_connect_timeout 30m;
        proxy_read_timeout    30m;
        proxy_send_timeout    30m;
        proxy_set_header      X-Forwarded-For "$proxy_add_x_forwarded_for";
        proxy_set_header      X-Forwarded-Proto "$scheme";
        proxy_set_header      Upgrade "$http_upgrade";
        proxy_set_header      Connection $connection_upgrade;
        proxy_cache_bypass    $http_upgrade;
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Allow-Credentials' 'true' always;
            add_header 'Access-Control-Allow-Methods' 'PUT, GET, POST, OPTIONS, DELETE, PATCH' always;
            add_header 'Access-Control-Allow-Headers' 'DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-csrf-token' always;
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }
    }
}

config on docker-compose-nginx.yml

version: '3.8'

services:
  proxy:
    image: nginx
    container_name: proxy
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    volumes:
      - "../proxy:/etc/nginx/templates"
    environment:
      BACK_PROXY_PASS: ${BACK_PROXY_PASS:-http://ipaddress:4000}
      FRONT_PROXY_PASS: ${FRONT_PROXY_PASS:-http://ipaddress:3000}
    ports:
      - 7121:7121
      - 8080:8080
      - 8081:8081
@vbaranov
Copy link
Member

vbaranov commented Sep 4, 2023

Did you set NEXT_PUBLIC_API_PORT=7121 for the frontend?

@vbaranov vbaranov added the waiting on feedback Waiting for original opener to respond if bug is fixed label Sep 4, 2023
@ekawibisono
Copy link
Author

ekawibisono commented Sep 5, 2023

when I added the port, there was an error response on the websocket

image

I Show configure .env frontend

#API Configure
NEXT_PUBLIC_API_HOST=ipaddress
NEXT_PUBLIC_API_PORT=7121
NEXT_PUBLIC_API_PROTOCOL=http
NEXT_PUBLIC_API_BASE_PATH=/
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws

NEXT_PUBLIC_STATS_API_HOST=http://ipaddress:8080
NEXT_PUBLIC_NETWORK_NAME=TEST
NEXT_PUBLIC_NETWORK_SHORT_NAME=TT
NEXT_PUBLIC_NETWORK_ID=22012
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=TEST
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=TT
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_RPC_URL=http://ipaddress:9545/
NEXT_PUBLIC_APP_HOST=ipaddress
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_VISUALIZE_API_HOST=http://ipaddress:8081
NEXT_PUBLIC_IS_TESTNET=true
NEXT_PUBLIC_NETWORK_LOGO=Logo_IMAGE
NEXT_PUBLIC_NETWORK_LOGO_DARK=Logo_IMAGE
NEXT_PUBLIC_NETWORK_ICON=Logo_IMAGE
NEXT_PUBLIC_NETWORK_ICON_DARK=Logo_IMAGE
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND=radial-gradient(circle farthest-corner at top right, #19C3CF 0%, #0A4A4D 100%);
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR=rgb(255, 255, 255)
NEXT_PUBLIC_AD_TEXT_PROVIDER=none
NEXT_PUBLIC_AD_BANNER_PROVIDER=none
NEXT_PUBLIC_HIDE_INDEXING_ALERT=true

#Blockchain interaction (writing to contract, etc.)
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=ID_PROJECT
NEXT_PUBLIC_NETWORK_RPC_URL=http://ipaddress:9545/
NEXT_PUBLIC_NETWORK_NAME=TEST
NEXT_PUBLIC_NETWORK_ID=22012
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=TEST
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=TT
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18

CC : @vbaranov

@vbaranov
Copy link
Member

vbaranov commented Sep 5, 2023

@ekawibisono port setting for websocket should be processed in blockscout/frontend#1139

@ekawibisono
Copy link
Author

@ekawibisono port setting for websocket should be processed in blockscout/frontend#1139

Check my reply on your post in repository frontend

@hentai8
Copy link

hentai8 commented Nov 23, 2023

I have the same problem.How can i solve it.

@ekawibisono
Copy link
Author

I have the same problem.How can i solve it.

hello, please ask in discord blockscout Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on feedback Waiting for original opener to respond if bug is fixed
Projects
None yet
Development

No branches or pull requests

3 participants