#nginx #proxy #reverse
Вопрос:
Я изо всех сил пытаюсь преобразовать свой обратный прокси-сервер apache в nginx.
вот мои настройки apache
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName IP_host
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
ProxyPass /.well-known !
Alias /.well-known/pki-validation /etc/pki/validation
<Directory /etc/pki/validation/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ProxyVia Off
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://www.example.com/
ProxyPassReverse / http://www.example.com/
RequestHeader unset Accept-Encoding
<Location "/">
Header edit Location "example.com" "IP_host"
SetEnv filter-errordocs
AddOutputFilterByType SUBSTITUTE text/html
AddOutputFilterByType SUBSTITUTE text/css
AddOutputFilterByType SUBSTITUTE application/javascript
AddOutputFilterByType SUBSTITUTE application/json
Substitute "s/example.com/IP_host/in"
</Location>
я попробовал эти настройки на nginx, но безуспешно
server {
listen 80;
location / {
# rewrite tag html link '{$IP_host}' '{host}'
sub_filter '<a href="http://example.com' '<a href="http://$host';
sub_filter_once off;
proxy_pass http://example.com;
#proxy_cache_bypass $http_upgrade;
# Proxy headers
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Port $server_port;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
я думаю, что пропустил замену html/css, но я не знаю, как включить ее в конфигурацию nginx