Sounds like you need to configure virtual directories. The following cmdlets will display the current settings:
Get-ClientAccessServer | FT Name,AutodiscoverServiceInternalUri -Autosize
Get-OabVirtualDirectory | FL ExternalURL,InternalURL
Get-WebServicesVirtualDirectory | FL ExternalURL,InternalURL
Get-OutlookAnywhere | FT Name,*hostname* -Autosize
For the first four, the output will show the "internal" name of the Exchange server. What you need in order to make it work is to decide what name it will have both for internal and external access. Generally, the suggested approach is to user split DNS and have the certificate to include the FQDN of the server, which will be only the "external" one, as no CA will issue a certificate for the internal name.
For example, you decide to use mail.contoso.com.
This will require you to create DNS zone in your internal DNS which will be named contoso.com. Define an A record that will point to the internal IP of the Exchange server, same should be done for the access from outside ( as well open port 443).
in order to define the vdirs correctly, I suggest you use the following script:
For the last setting, define the EXPR as explained here: