0

I need to setup ssl for 2 websites: admin and client, with the same domain abc.example.com but different port.

  1. The admin page, you need to setup:
  • http: 8080
  • https: 8443
  • root /var/www/admin/public
server {
        listen 8080;
        server_name abc.example.com;
        root /var/www/admin/public;
        index index.php;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        location ~ \.php$ {
           try_files $uri =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/run/php-fpm/www.sock;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
         }

        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }
    }

   server {
         listen 8443 ssl;
         server_name abc.example.com;
         root /var/www/admin/public;
         index index.php;
         error_log  /var/log/nginx/error.log;
         access_log /var/log/nginx/access.log;

         ssl_certificate /etc/pki/tls/certs/_example.com.crt;
         ssl_certificate_key /etc/pki/tls/certs/_example.com.key;
         location ~ \.php$ {
           try_files $uri =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/run/php-fpm/www.sock;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
         }
    
        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }
    }
  1. The client page, you need to setup:
  • http: 80
  • https: 443
  • root /var/www/client/public
server {
        listen 80;
        server_name abc.example.com;
        root /var/www/client/public;
        index index.php;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        location ~ \.php$ {
           try_files $uri =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/run/php-fpm/www.sock;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
         }

        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }
    }

     server {
         listen 443 ssl;
         server_name abc.example.com;
         index index.php;
         error_log  /var/log/nginx/error.log;
         access_log /var/log/nginx/access.log;
         ssl_certificate /etc/pki/tls/certs/_example.com.crt;
         ssl_certificate_key /etc/pki/tls/certs/_example.com.key;
         root /var/www/client/public;
         location ~ \.php$ {
           try_files $uri =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/run/php-fpm/www.sock;
           fastcgi_index index.php;
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
         }
        
        location / {
          try_files $uri $uri/ /index.php?$query_string;
        } 
    }

I have the above config, the port 80,443,8080 is connected successfully but port 8443 is not working. Although on the server I have already opened port 8443. enter image description here

Specifically, when I access the link https://abc.example.com:8443/, the browser says this site can't be reached enter image description here

If anybody face the problem and know how to fix it.Hope you'll help me to solve it. Thank you so much!

Nguyen Hung
  • 127
  • 2
  • 10

0 Answers0