1、nginx重定向到其它网址
location / {
return 301 https://www.xxx.com/;
}
2、nginx代理其它网址(upstream 的详细配置,自己查阅一下资料。)
upstream emba_api {
server 127.0.0.1:40011;
}
server
{
listen 80;
server_name www.***.com;
index index.php index.html index.htm default.php default.htm default.html;
location /api/ {
proxy_pass https://www.xxx.com/api/;
proxy_set_header Host $host:$server_port;
}
}
3、简单的完整重定向配置
upstream project {
server 127.0.0.1:44411;
}
upstream emba_api {
server 127.0.0.1:40011;
}
server
{
listen 80;
server_name www.***.com;
index index.php index.html index.htm default.php default.htm default.html;
client_max_body_size 200M;
location / {
return 301 https://www.xxx.com/;
}
location /api/ {
proxy_pass http://emba_api/api/;
proxy_set_header Host $host:$server_port;
}
location ~ ^/enroll(/|\.html)? {
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Nginx-Proxy true;
proxy_set_header X-Scheme $scheme;
proxy_set_header HOST $host;
proxy_pass http://project;
proxy_redirect off;
}
}
|