Linux Nginx - how redirect port 80 to 443 (http to https)

Linux Nginx - how redirect port 80 to 443 (http to https)

Hi,

I would need to set up redirection on the linux webserver nginx as follows:

1.) anything on port 80 via http is redirected to port 443 with https
2.) what comes to port 88 from the inside stays on port 88

Thanks

REPLY


Hi,

you could do such a redirect for the nginx webserver as follows:


server {
listen 80;
server_name app.cloud.up4.cz www.app.cloud.up4.cz;
return 301 https://$host$request_uri;
}

server {
listen 88;
root /var/www/is/www;
index index.php index.html;
server_name app.cloud.up4.cz www.app.cloud.up4.cz;

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
client_max_body_size 999M;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}

location ~ /\.ht {
deny all;
}

listen 444 ssl;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.app.cloud.up4.cz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.app.cloud.up4.cz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Související obsah

linux

bash

terminal

webserver

nginx

ssl

https

Komentáře

Vaše reakce na Linux Nginx - jak přesměrovat port 80 na 443 (http na https)

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.