У меня два сайта.
example.com example.com/abc
Я хотел бы пройти прокси-сервер при доступе к example.com/abc с другого IP-адреса.
Вот мои текущие сайты с поддержкой nginx.
Я также нашел эту статью со следующим кодом. Мне интересно, как лучше всего реализовать это изменение в моем текущем файле.
образец кода
location ~/app2(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://aaa.bbb.ccc.ddd:8001$1;
}
вот моя текущая конфигурация nginx:
# Ansible manage
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name example.com;
location /yaan2/ {
proxy_pass http://104.248.170.227/3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /srv/www/example/logs/access.log main;
error_log /srv/www/example/logs/error.log;
root /srv/www/example/current/web;
index index.php index.htm index.html;
add_header Fastcgi-Cache $upstream_cache_status;
# Specify a charset
charset utf-8;
# Set the max body size equal to PHP's max POST size.
client_max_body_size 25m;
# Multisite rewrites
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) /wp$2 last;
rewrite ^(/[^/]+)?(/.*\.php) /wp$2;
}
# SSL configuration
include h5bp/directive-only/ssl.conf;
include h5bp/directive-only/ssl-stapling.conf;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_buffer_size 1400; # 1400 bytes to fit in one MTU
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; ";
ssl_certificate /etc/nginx/ssl/letsencrypt/example-696196a-bundled.cert;
ssl_certificate_key /etc/nginx/ssl/letsencrypt/example.key;
include acme-challenge-location.conf;
include includes.d/all/*.conf;
include includes.d/example/*.conf;
# Prevent PHP scripts from being executed inside the uploads folder.
location ~* /app/uploads/.*\.php$ {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
include h5bp/directive-only/cache-file-descriptors.conf;
include h5bp/directive-only/extra-security.conf;
include h5bp/directive-only/x-ua-compatible.conf;
include h5bp/location/cross-domain-fonts.conf;
include h5bp/location/protect-system-files.conf;
add_header Content-Security-Policy "frame-ancestors 'self'" always;
# Conditional X-Frame-Options until https://core.trac.wordpress.org/ticket/40020 is resolved
set $x_frame_options SAMEORIGIN;
if ($arg_customize_changeset_uuid) {
set $x_frame_options "";
}
add_header X-Frame-Options $x_frame_options always;
location ~ \.php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass unix:/var/run/php-fpm-wordpress.sock;
}
}
# Redirect to https
server {
listen [::]:80;
listen 80;
server_name example.com;
include acme-challenge-location.conf;
include includes.d/all/*.conf;
include includes.d/example/*.conf;
location / {
return 301 https://$host$request_uri;
}
}