merdin's avatar

Build a webserver with Ubuntu Server and Nginx.

I don't know if I can ask questions like this here, but here we go:

I installed Ubuntu Server 18.04.2 LTS on an old iMac. I installed Nginx, MySQL, phpMyAdmin and about to install let's encrypt -> I have myowndomainname.com which I can use. I followed this tutorial/manual: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04

Now I want to know how I can make my website which is running on a private ip address (192.168.x.x) run on my public ip adres. Can I do this with port forwarding? Or can I change my Ubuntu Server ipv4 to the public ip address? -> I know this not really secure.

What is the best solution for this? Which ports do I need to forward if I want to use HTTP/HTTPS/SSH/FTP? My provider gives me these options with portforwarding:

Local IP Local start port Local end port Extern start port Extern end port Protocol: TCP/UDP/BOTH I also can configure trigger ports or add ipv4-filter-rules

The nginx file looks like this:

server {
        listen *:80;
        root /var/www/html/myowndomainname.com;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name myowndomainname.com www.myowndomainname.com;

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

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

        location ~ /\.ht {
                deny all;
        }
}

I also tried to disable ufw, which didn't help. I tried to use my public ip with port :80 and other ports. This didn't do anything.

0 likes
1 reply
Tray2's avatar

You need to forward port 80 in your router to your local ip and then if you have a static ip from your ISP you can connect a domain to that ip. If you don't have a static you can use dyndns or similar service.

Please be aware that if you haven't set up everything correctly on the server it might be a security risk.

I also suggest that you configure ssl and use https instead of port 80.

Please or to participate in this conversation.