Stackoverflowers, 我需要创建一个指向http://example.com的反向代理,但不是将其重定向到网站,而是需要重写它,而不需要更改URL。我的nginx反向代理的IP是http://10.31.0.147/。 不幸的是,我当前的配置无效:
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
rewrite ^/$ http://example.com break;
proxy_redirect off;
}
}
如果我从重写命令中删除http://我收到错误" 404 Not Found"如果我保持原样,我会被重定向,并且网址会更改为www.example.com。有没有办法解决这个问题,而不是改变http://10.31.0.147。在NGINX文档中,我每次使用" http://"页面正在重定向。
答案 0 :(得分:0)
我没有使用重写,而是使用了代理通行证
PHP Fatal error: Uncaught Error: [] operator not supported for strings in /opt/agews64/www/includes/class/AGEws/Mail.php:134
Stack trace:
0 /opt/agews64/www/includes/class/PHPMailer/SMTP.php(220): AGEws_Mail::{closure}('CLIENT -> SERVE...', 1)
1 /opt/agews64/www/includes/class/PHPMailer/SMTP.php(991): PHPMailer_SMTP->edebug('CLIENT -> SERVE...', 1)
2 /opt/agews64/www/includes/class/PHPMailer/SMTP.php(885): PHPMailer_SMTP->client_send('QUIT\r\n')
3 /opt/agews64/www/includes/class/PHPMailer/SMTP.php(827): PHPMailer_SMTP->sendCommand('QUIT', 'QUIT', 221)
4 /opt/agews64/www/includes/class/PHPMailer.php(1721): PHPMailer_SMTP->quit()
5 /opt/agews64/www/includes/class/PHPMailer.php(670): PHPMailer->smtpClose()
6 /opt/agews64/www/includes/class/AGEws/Mail.php(147): PHPMailer->__destruct()
7 /opt/agews64/www/includes/class/AGEws/Mail.php(118): AGEws_Mail::sendWithLog(NULL, 'SMTP Error: Dat...', 3)
8 /opt/agews64/www/includes/class/AGEws/Cron/Import.php(154): AGEws_Mail::prepareAndSendWithLog('SMTP Error: Dat...', Array, 'Risu in /opt/agews64/www/includes/class/AGEws/Mail.php on line 134
答案 1 :(得分:0)
很简单:
location / {
proxy_pass https://$server_name$request_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
}