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

Fix CORS error for UI #121

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
REVERSE_PROXY_PORT=8000
REVERSE_PROXY_UI_PORT=8080

CFG_VERSION=latest
CGW_VERSION=latest
Expand Down
6 changes: 6 additions & 0 deletions container_env_files/cgw.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ AUTH_TOKEN=your_privileged_endpoints_token
# Log level
LOG_LEVEL=info
# LOG_SILENT=true

# Alerts provider
ALERTS_PROVIDER_SIGNING_KEY=''
ALERTS_PROVIDER_API_KEY=''
ALERTS_PROVIDER_ACCOUNT=''
ALERTS_PROVIDER_PROJECT=''
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- ./data/events-db:/var/lib/postgresql/data
<<: *pghealthcheck
<<: *pghealthcheck

# Safe Transaction Service
txs-redis:
Expand Down Expand Up @@ -159,8 +159,8 @@ services:
- container_env_files/ui.env
depends_on:
- nginx
ports:
- "${REVERSE_PROXY_UI_PORT}:8080"
expose:
- 8080

general-rabbitmq:
image: rabbitmq:alpine
Expand All @@ -170,13 +170,13 @@ services:
timeout: 30s
retries: 3
start_period: 15s

events-web:
image: safeglobal/safe-events-service:${EVENTS_VERSION}
env_file:
- container_env_files/events.env
- container_env_files/events.env
depends_on:
events-db:
condition: service_healthy
general-rabbitmq:
condition: service_healthy
events-db:
condition: service_healthy
general-rabbitmq:
condition: service_healthy
27 changes: 26 additions & 1 deletion docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ http {
keepalive 32;
}

upstream ui_server {
ip_hash; # For load-balancing
server ui:8080 fail_timeout=0;
#
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response
keepalive 32;
}

server {
access_log off;
listen 8000 deferred;
Expand Down Expand Up @@ -104,7 +113,6 @@ http {
}

location /cfg/ {
proxy_pass http://cfg_app_server/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
Expand All @@ -114,6 +122,8 @@ http {
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://cfg_app_server/;

# They default to 60s. Increase to avoid WORKER TIMEOUT in web container
proxy_connect_timeout 60s;
proxy_read_timeout 60s;
Expand Down Expand Up @@ -148,5 +158,20 @@ http {
proxy_set_header X-Real-IP $remote_addr;
add_header Front-End-Https on;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://ui_server/;

proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header Front-End-Https on;
}

}
}
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- **Tx Service** is the core of the Safe. It indexes multisig transactions, module transactions, token transfers, collects signatures... There must be **1 Tx Service per Chain**, with different workers, PostgreSQL, Redis and RabbitMQ.
- **Config Service** holds configuration for every Chain (blockexplorer, tx service url, apps enabled, wallets enabled...). **1 instance of the Config Service supports multiple Chains**
- **Client Gateway** provides an API optimized for clients (web ui, android, ios...). **1 instance of the Client Gateway supports multiple Chains**
- **Safe Events Service** handle Safe indexing events from Transaction Service and deliver as HTTP webhooks.
- **Events Service** handles Safe indexing events from Transaction Service and deliver as HTTP webhooks.

## Setup

Expand Down
4 changes: 1 addition & 3 deletions docs/running_locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ For the Events service, follow these steps:

# Safe Web App

The Safe Web app will be available at at http://localhost:8080 although check the output of `docker compose` to see that the container is already running, as in some step-ups, it can take longer than expected ( >15 minutes).

To configure the port in which the Safe Web app will be reachable, look into our sample [.env](../.env.sample) file. The value of `REVERSE_PROXY_UI_PORT` defines this.
The Safe Web app will be available at at http://localhost:8000/ although check the output of `docker compose` to see that the container is already running, as in some step-ups, it can take longer than expected ( >15 minutes).

Add your `NEXT_PUBLIC_INFURA_TOKEN` value if its required for the chain RCP uri in the [container_env_files/ui.env](../container_env_files/ui.env) file.

Expand Down