Home > AI > Frontend > Next.js >

Update Next.js to eliminate the 3000 port

Verify port availability

curl https://localhost:3000

It throws me error that SSL certificate is not for localhost, so it should be curl https://english92.com:3000

Verify modules are installed

sudo httpd -M | grep proxy


proxy_module (shared) 
proxy_fcgi_module (shared) 
proxy_http_module (shared) 
proxy_wstunnel_module (shared)


sudo httpd -M | grep ssl

ssl_module (shared)
sudo grep 'LoadModule ssl_module' /etc/apache2/conf/httpd.conf

<VirtualHost *:444>
  ServerName www.english92.com
  ServerAlias english92.com

  ProxyPreserveHost On
  ProxyPass / https://english92.com:3000/
  ProxyPassReverse / https://english92.com:3000/
  RequestHeader set X-Forwarded-Proto "https"
  RequestHeader set X-Forwarded-Port "444"

  ErrorLog /etc/apache2/logs/rp_error.log
  CustomLog /etc/apache2/logs/rp_access.log combined
</VirtualHost>

Then I got Internal Server Error when visiting https://english92.com. Upon checking the error log by

I got these two error messages

[Sun Aug 11 12:10:06.024716 2024] [core:error] [pid 346027:tid 346093] [remote 72.167.39.37:3000] AH01961:  failed to enable ssl support [Hint: if using mod_ssl, see SSLProxyEngine]

[Sun Aug 11 12:10:06.024725 2024] [proxy:error] [pid 346027:tid 346093] AH00961: https: failed to enable ssl support for 72.167.39.37:3000 (english92.com)

This indicates Ensure mod_ssl is Installed and Enabled and Enable SSLProxyEngine

<VirtualHost *:444>
    ServerName yourdomain.com

    ProxyPreserveHost On
    ProxyPass / https://backendserver:3000/
    ProxyPassReverse / https://backendserver:3000/

    <IfModule ssl_module>
      SSLProxyEngine On
      SSLProxyVerify None
      SSLProxyCheckPeerCN Off
      SSLProxyCheckPeerName Off
      SSLProxyCheckPeerExpire Off
    </IfModule>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

This block is working!

ProxyPreserveHost On
ProxyPass / https://english92.com:3000/
ProxyPassReverse / https://english92.com:3000/

<IfModule ssl_module>
  SSLProxyEngine On
  SSLProxyVerify None
  SSLProxyCheckPeerCN Off
  SSLProxyCheckPeerName Off
  SSLProxyCheckPeerExpire Off
</IfModule>

<VirtualHost 127.0.0.1:444 72.167.39.37:444 *:444>

  ProxyPreserveHost On
  ProxyPass / https://english92.com:3000/
  ProxyPassReverse / https://english92.com:3000/

  <IfModule ssl_module>
    SSLProxyEngine On
    SSLProxyVerify None
    SSLProxyCheckPeerCN Off
    SSLProxyCheckPeerName Off
    SSLProxyCheckPeerExpire Off
  </IfModule>

</VirtualHost>

Leave a Reply