iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💭
How to Use Codex Through a Proxy
Idea
There are times when I want to use codex on a login node while using a supercomputer. However, sometimes (at least on the supercomputer I use), access to the OpenAI API is blocked, making it impossible to use codex.
To solve this problem, I set up a reverse proxy to enable codex access, and I am documenting the process here.
I used the following configuration:
- On the remote side, codex is set to call 127.0.0.1:18080.
- Remote 127.0.0.1:18080 is forwarded to localhost:8888 on the local side via a reverse proxy.
-
tinyproxysends the actual HTTP/HTTPS requests.
Procedure
1. Setting up the reverse proxy
I used tinyproxy for the local proxy server.
Local
yay -S tinyproxy # Please download according to your distribution
sudo systemctl enable tinyproxy
sudo systemctl start tinyproxy
# systemctl status tinyproxy # to check if it is working
ssh -R 18080:127.0.0.1:8888 server # Replace 'server' with the target server you are accessing
Test
# Local
wget -e https_proxy=http://127.0.0.1:8888 https://api.openai.com/v1/models
# Server
wget -e https_proxy=http://127.0.0.1:18080 https://api.openai.com/v1/models
If successful, an Authentication Failed error will be returned.
--2026-02-16 20:40:47-- https://api.openai.com/v1/models
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Connecting to 127.0.0.1:8888... connected.
Proxy request sent, awaiting response... 401 Unauthorized
Username/Password Authentication Failed.
If it fails, a Connection refused error will appear.
--2026-02-16 20:40:07-- https://api.openai.com/v1/models
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Connecting to 127.0.0.1:18080... failed: Connection refused.
2. Launching codex using the proxy
Add the following to your ~/.bashrc:
export HTTPS_PROXY="http://127.0.0.1:18080"
export HTTP_PROXY="http://127.0.0.1:18080"
That is all.
From now on, you can launch codex and use it without any restrictions.
codex
Discussion