I am trying to proxy java application runs on port 4443
using nginx. My nginx server block is like below:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream ovserver {
server example.com:4443;
}
server {
server_name ov.example.com www.ov.example.com;
location / {
proxy_pass https://ovserver;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_intercept_errors on;
proxy_redirect off;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/ov.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ov.example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = ov.example.com) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name ov.example.com www.ov.example.com;
return 404;
}
I need to direct all the requests generate by the java application in port 4443 to given host. Ex:
https://example.com:4443/something/here => https://ov.example.com/something/here
wss://example.com:443/something/here => wss://ov.example.com/something/here
But with my current configuration, it is still not working. Any suggestions appreciated.
UPATE 1
curl request examples:
curl --user name:password https://example.com:4443/something/api/here
curl: (60) SSL certificate problem: self signed certificate
curl --user name:password https://ov.example.com/something/api/here
{"numberOfElements":0,"content":[]} # expected response
UPDATE 2
curl --user name:password https://example.com:4443/something/api/here --key /etc/letsencrypt/live/ov.example.com/privkey.pem --cert /etc/letsencrypt/live/ov.example.com/cert.pem
#response
SSL certificate problem: self signed certificate