Как использовать связку nginx — apache на работающем сайте в качестве прокси ?

Подскажите пожалуйста, на сайте domain.ru с ip 1.1.1.1 стоял apache 2.2 и в конфиге были такие строки

ProxyRequests On
ProxyVia Block
AllowCONNECT 21 25 110 443 22 554 563 5190 1080 8080 5140 5160 4000 1478 1479 1480 8008 1480>

Order deny,allow
deny from all
allow from xxx.xx.xx.xx

Апач работал, как прокси. Но возникла необходимость поставить nginx.
Конфиг nginx

# user nginx;
worker_processes  4;
timer_resolution 100ms;

# error_log  /dev/null;
error_log  /usr/local/nginx/logs/error.log  crit;
#pid        logs/nginx.pid;
worker_rlimit_nofile 200000;
worker_priority -5;
events { worker_connections  4000;

multi_accept on; }
http { include       mime.types; default_type  application/octet-stream;
types { text/plain    data;  }
    log_format  main  '$remote_addr - $remote_user [$time_local] $host $request
'
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_src_client_ip"';

#access_log /usr/local/nginx/logs/access.log  main;
access_log off;

# Caches information about open FDs, freqently accessed files.
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;


    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay    on;
    
    gzip           on;
    gzip_min_length 10240;
    gzip_buffers 64 8k;
    gzip_comp_level 3;
    gzip_http_version 1.1;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plan application/xml application/x-javascript text/css text/xml text/javascript;
    gzip_disable "msie6";
    client_body_timeout 10;
    client_header_timeout 10;
    send_timeout 2;
    
    keepalive_timeout  30;
    keepalive_requests 1000;
    
    server_tokens off;
    server_names_hash_bucket_size 64;
    proxy_buffers     100 64k;
    proxy_read_timeout 300;
    proxy_send_timeout 300;
    client_max_body_size 1500m;
    reset_timedout_connection on;

proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=one:16m inactive=7d max_size=1024m;
proxy_temp_path /var/cache/nginx/temp;

server {
      listen       *:80;
      server_name   *.com;
location /nginx_status { stub_status on; access_log off; allow 1.1.1.1; deny all; }
location /munin { alias   /var/www/html/munin; autoindex on; auth_basic "Munin"; auth_basic_user_file /etc/munin/munin-htpasswd; }
      location / {
            proxy_pass        http://1.1.1.1:8181;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
      }

}

server {
      listen       *:80;
      server_name   www.domain.ru domain.ru;
location /nginx_status { stub_status on; access_log off; allow 1.1.1.1; deny all; }
location /munin { alias   /var/www/html/munin; autoindex on; auth_basic "Munin"; auth_basic_user_file /etc/munin/munin-htpasswd; }
# proxy_temp_path /var/cache/nginx/domain.ru;

location / {
#            $host='domain.ru:80'
            proxy_pass http://1.1.1.1:80;
            proxy_set_header Host domain.ru;
        proxy_redirect off;
}
        
# location /administrator {
location ~*(administrator|comprofiler)* {
         proxy_cache off;
         proxy_pass        http://1.1.1.1:8181;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Real-IP $remote_addr;

}

}
}


Теперь прокси перестал работать.
Ранее на голом апаче с помощью настроек выше можно было использовать адрес сайта и 80 порт в качестве прокси, указав его в настройках браузера. Для повышения производительности был добавлен nginx, но функционал прокси отвалился. Сейчас нужно его вернуть. На сервере открыт только 80 и 22 порты, других не будет. Подскажите, как вернуть функционал прокси?
  • Вопрос задан
  • 2806 просмотров
Пригласить эксперта
Ответы на вопрос 2
dmitriylyalyuev
@dmitriylyalyuev
Nginx не является проксей в обычном понимании. Т.е. его не заставить работать в вашем случае так же, как и Апач.
Ответ написан
Комментировать
@Magi Автор вопроса
Мне как-то подсказывали, что nginx может работать в качестве forward proxy. Находил пример этого, но к сожалению не получилось.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы