我想在代理服务器后面提供我的Restful API,我不知道如何将请求重定向到Spring引导应用程序,因此可以使用域名访问它。
我的spring启动应用程序使用spring-boot-starter-tomcat运行,应用程序部署正常,我可以使用服务器上的java -jar myApplication.jar部署它。
通过在浏览器上编写https://1.2.3.4:8090,也可以远程访问该应用程序。
我使用NGINX(版本:nginx / 1.11.10)作为反向代理。这是我的配置:
SUM(case when AverageServiceTime < EstimateServiceTime then 1
else 0
end) / COUNT(I.Id) ServiceSuccess
from Interaction I
include /etc/nginx/modules.conf.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalºº 0;
keepalive_timeout 65;
#tcp_nodelay on;
#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
server_tokens off;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
服务器响应状态代码:301永久移动。
控制台输出是:
server {
listen 443 ssl;
server_name fakedomain.com;
ssl on;
ssl_certificate /../certificate.pem;
ssl_certificate_key /../certificate.key.pem;
ssl_session_cache shared:SSL:10m;
location /server/ {
proxy_redirect http://1.2.3.4:8090 https://fakedomain.com/;
proxy_pass_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_connect_timeout 5;
proxy_read_timeout 240;
proxy_intercept_errors on;
proxy_pass http://1.2.3.4:8090;
}
}
答案 0 :(得分:0)
您只需要proxy_pass
而不是proxy_redirect
。
您已在此行发送了重定向:
proxy_redirect http://1.2.3.4:8090 https://fakedomain.com/;