Я пытаюсь узнать, как я могу использовать nginx для ответа на 443, но используя приложение на порту 6040, мне нужно ответить nginx, как приложение 6040, вызванное 443 ssl, кто-нибудь знает, как это возможно?
] Regars
Я предполагаю, что ваше приложение просматривает запросы http на порту 6040, работает на том же компьютере, что и ваш сервер nginx. Если ваше приложение перечисляет запросы https на порт 6040, см. Nginx https upstreams.
Создайте сервер, который прослушивает порт 443 на вашем общедоступном ip и действует как прокси для вашего внутреннего приложения на порту 6040.
/etc/nginx/sites-available/www.example.com.vhost
server {
# Listen on port 443 for both IPv4 and IPv6 and turn on http2 support.
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
ssl on;
# Paths to certificates assuming you're using let's encrypt / certbot
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
# There's much more directives you should fine tune for https, but that's another task.
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:6040;
proxy_read_timeout 90;
proxy_redirect http://localhost:6040 https://www.example.com;
}
}
Я предполагаю, что ваше приложение просматривает запросы http на порту 6040, работает на том же компьютере, что и ваш сервер nginx. Если ваше приложение перечисляет запросы https на порт 6040, см. Nginx https upstreams.
Создайте сервер, который прослушивает порт 443 на вашем общедоступном ip и действует как прокси для вашего внутреннего приложения на порту 6040.
/etc/nginx/sites-available/www.example.com.vhost
server {
# Listen on port 443 for both IPv4 and IPv6 and turn on http2 support.
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
ssl on;
# Paths to certificates assuming you're using let's encrypt / certbot
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
# There's much more directives you should fine tune for https, but that's another task.
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:6040;
proxy_read_timeout 90;
proxy_redirect http://localhost:6040 https://www.example.com;
}
}