Change listening port on NGINX Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
FedericoCoppola
Posts: 7
Joined: Mon Feb 04, 2019 10:56 pm

Change listening port on NGINX

Post by FedericoCoppola »

Hello,
I have configured the listening port of my NGINX server on DietPI.

This is my configuration after change, the new port listening is 8080.

Code: Select all

#D I E T - P I
# /etc/nginx/sites-available/default

server {

        listen 8080 default_server;
        listen [::]:8080 default_server;

        root /var/www;
        index index.php index.html index.htm;

        server_name "$hostname";

        location / {
                try_files $uri $uri/ =404;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /var/www;
        }

        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass php;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        include /etc/nginx/sites-dietpi/*.conf;

}
The problem is that the web server continue to listening on port 80, in fact when I do not specify the port on my browser I will see the default web page of the web server.
I want that this server listens only on port 8080.

Thanks
FedericoCoppola
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: Change listening port on NGINX

Post by MichaIng »

@FedericoCoppola
Sorry for asking, but you restarted webserver and PHP?

Code: Select all

systemctl restart nginx
systemctl restart php7.0-fpm
FedericoCoppola
Posts: 7
Joined: Mon Feb 04, 2019 10:56 pm

Re: Change listening port on NGINX

Post by FedericoCoppola »

Thanks! :)
Post Reply