Skip to content
Open
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
46 changes: 8 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
FROM debian:latest
# Используем nginx:alpine как базовый образ
FROM nginx:alpine

ARG MODULE=ngx_http_proxy_connect_module
ARG VERSION=1.19.3
ARG PREFIX=/etc/nginx

# Required packages
RUN set -eux; \
apt-get update; \
apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates git wget \
build-essential libssl-dev libpcre3-dev zlib1g-dev; \
rm -rf /var/lib/apt/lists/*
# Удаляем конфигурацию по умолчанию
RUN rm /etc/nginx/conf.d/default.conf

# Build nginx
WORKDIR /usr/src/
RUN set -eux; \
git clone https://github.com/chobits/$MODULE; \
wget http://nginx.org/download/nginx-$VERSION.tar.gz; \
tar xzf nginx-$VERSION.tar.gz; \
cd nginx-$VERSION; \
patch -p1 < ../$MODULE/patch/proxy_connect_rewrite_1018.patch; \
./configure \
--prefix=$PREFIX --sbin-path=/usr/bin \
--with-threads \
--with-http_ssl_module --add-module=../$MODULE; \
make; \
make install; \
make clean; \
cd -; \
rm -rf ./*

# Logging
RUN set -eux; \
ln -sf /dev/stdout $PREFIX/logs/access.log; \
ln -sf /dev/stderr $PREFIX/logs/error.log
# Копируем наш конфигурационный файл в нужную директорию
COPY conf/nginx.conf /etc/nginx/conf.d/nginx.conf

EXPOSE 80

STOPSIGNAL SIGQUIT

CMD ["nginx", "-g", "daemon off;"]
# Открываем порт 80
EXPOSE 8080
55 changes: 11 additions & 44 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,46 +1,13 @@
events {}

worker_processes 5;

http {
server {
listen 80;

# DNS servers
include resolver.conf;

# Allow direct connections
proxy_connect;
proxy_connect_read_timeout 30s;
proxy_connect_send_timeout 30s;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

# Permissive: no common web server ports bypass
# proxy_connect 1-79 81-8079 8081-65535;
# Restrictive: just default HTTPS port
proxy_connect_allow 443;

# Defaults to HTTPS
location / {
# Fallback to original connection scheme
error_page 502 = @fallback;

# Will only upgrade HTTP
if ($scheme != "http") {
return 502;
}

# Generated HTTPS bypass whitelist
include bypass/all.conf;

proxy_pass https://$http_host;
include proxy.conf;
}

location @fallback {
# Proxy any scheme
proxy_pass $scheme://$http_host;
include proxy.conf;
}
server {
listen 8080;

location / {
proxy_pass http://91.84.100.81:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}


23 changes: 23 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# fly.toml app configuration file generated for https-upgrader on 2025-05-20T15:04:44Z
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'https-upgrader'
primary_region = 'ams'

[build]

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
memory_mb = 1024