我正在尝试重定向:
AAA.myhost.com --> http://127.0.0.1:888/AAA
BBB.myhost.com --> http://127.0.0.1:888/BBB
第一:可以这样做吗?第二:我知道如何重定向到内部应用程序...我的 nginx 配置:
worker_processes 1;
user root root;
# 'user nobody nobody;' for systems with 'nobody' as a group instead
pid /run/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
}
http {
include mime.types;
upstream wordpress {
server 127.0.0.1:888 fail_timeout=0;
}
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;
server {
listen 80 default_server;
return 444;
}
server {
listen 80 deferred;
client_max_body_size 1M;
server_name www.host.com;
keepalive_timeout 5;
location / {
rewrite /wordpress redirect;
try_files $uri @proxy_to_wordpress;
}
location @proxy_to_wordpress {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://wordpress;
}
error_page 500 502 503 504 /500.html;
}
}
答案1
是的,这是可能的。只需server
为每个子域添加一个块,其中包含proxy_pass
指向目标的指令。例如:
server {
listen 80;
server_name aaa.example.com;
proxy_pass http://127.0.0.1:888;
}
您可能需要查看不同的代理配置指令来修改其行为。