从 nginx 转换为 apache

从 nginx 转换为 apache

Nginx的:

server {

listen 2083 ssl;
location / {
  rewrite ^(.*)$ $1?ip=$remote_addr break; 
    proxy_pass http://127.0.0.1:8080/;
    proxy_redirect     off;
    proxy_set_header   Host                  $http_host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $remote_addr;
access_log off;
log_not_found off;
        }
}

阿帕奇:

<VirtualHost *:2083>
<Location /
ProxyPass http://localhost:2082/ retry= 0
ProxyPassReverse http://localhost:2082/
ProxyPreserveHost On
ProxyErrorOverride Off
</Location>
</VirtualHost>

nginx 中的这部分:

rewrite ^(.*)$ $1?ip=$remote_addr break; 

我想要为 Apache 做这件事。

答案1

请记住,您仍然需要更多指令来正确设置 TLS - 我假设您为了简洁而省略了它们 :-)。请参阅以获得关于如何做到这一点的指示。

Listen 2083 https

<VirtualHost *:2083>

ProxyPass http://localhost:2082/ retry= 0
ProxyPassReverse http://localhost:2082/
ProxyPreserveHost On
ProxyErrorOverride Off

# Disables logging for this vHost
ErrorLog /dev/null
CustomLog /dev/null common

RewriteEngine On

# Redirects with 302, the L breaks from rule processing
RewriteRule ^(.*)$ $1?ip=%{REMOTE_ADDR} [R,L]

<Proxy http://localhost:2082/>
  Require all granted
  # Sets the X-Real-IP header.
  RequestHeader set X-Real-IP "%{REMOTE_ADDR}"
</Proxy>

</VirtualHost>

相关内容