Mobile app version of vmapp.org
Login or Join
Kevin317

: How do I hide the port in my URL? What am I missing? If I go to mysite.com:9999 I get my site, but not mysite.com Obviously the users shouldn't need to type in the port, so what do

@Kevin317

Posted in: #Apache #HttpdConf #Virtualhost

What am I missing? If I go to mysite.com:9999 I get my site, but not mysite.com Obviously the users shouldn't need to type in the port, so what do I need to do? I'm not really trying to hide the port so much as not require the user to type it in the URL. Is this an Apache configuration setting somewhere? Should I be looking at httpd.config, container config or elsewhere? It is a Virtual Host on Apache server. Any suggestions are appreciated.

Edit- the working virtual host blocks in virtualhosts.conf looks like this:

Near the start the virtual host entries are named something like this:

NameVirtualHost *:700
NameVirtualHost *:710
...
NameVirtualHost *:760


Below the working block for the http version looks like this:

<VirtualHost *:710>
ServerName webdev.url.com
ServerAdmin admin@url.com

# Comment out when OC4J instance is down for maintenance:
<IfModule mod_oc4j.c>
Oc4jMount
</IfModule>

# Uncomment when OC4J instance is down for maintenance:
# DocumentRoot "/org/dev"

# - Restrict 'Cross-Site-Tracking' or XST
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

<IfModule mod_dir.c>
DirectoryIndex index.jsp
</IfModule>
ErrorLog "|/opt/app/oracle/product/AS10.1.2/Apache/Apache/bin/rotatelogs/logs/dev_error_log 440"
CustomLog "|/opt/app/oracle/product/AS10.1.2/Apache/Apache/bin/rotatelogs/logs/dev_access_log 440" common


<Location "/pls/dev">
Order deny,allow
Deny from all
Allow from ####internal ip addresses####
</Location>

</VirtualHost>


The new one that requires the port to be specified looks like this:

## - for Mobile
<VirtualHost *:770>
ServerName mdev.url.com
ServerAdmin admin@url.com

# Comment out when OC4J instance is down for maintenance:
<IfModule mod_oc4j.c>
Oc4jMount / msitedev
</IfModule>

# - Restrict 'Cross-Site-Tracking' or XST
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

<IfModule mod_dir.c>
DirectoryIndex m.jsp
</IfModule>

ErrorLog "|/opt/app/oracle/product/AS10.1.2/Apache/Apache/bin/rotatelogs/logs/mdev_error_log 440"
CustomLog "|/opt/app/oracle/product/AS10.1.2/Apache/Apache/bin/rotatelogs/logs/mdev_access_log 440" common


# <Location "/org/dev">
# Order deny,allow
# Deny from all
# Allow from ####
# </Location>


</VirtualHost>


Again, I am just trying to figure out if something here is suppressing the need to enter the port # (eg. 710) in the URL. Upon examination, there don't appear to be any htaccess files anywhere.

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

4 Comments

Sorted by latest first Latest Oldest Best

 

@Moriarity557

I only now realize that I never posted the specific answer to my issue.

In the end we needed to add details to webcache.xml to allow the URL to work without a port specified in the URL.

10% popularity Vote Up Vote Down


 

@Hamaas447

Here is the manual for DNS SRV records (RFC 2782) which can be used to change the default port to match what you actually use:

_http._tcp.example.com. IN SRV 0 5 80 example.com.

where next to last field is port, which can have any real value. DNS SRV records can redefine default http port for domain or only for (some) hosts inside domain

10% popularity Vote Up Vote Down


 

@Gail5422790

When you type the URL in a web browser, www.foo.com, it will always attempt to connect on port 80.

It's not so much that the port is being hidden, but rather that it's being assumed, since port 80 is the default for HTTP requests.

Along the same line, if you browse to www.foo.com, it will always attempt to connect on port 443 unless you specify another port (https://www.foo.com:8080). Port 443 is the default port for SSL/TLS requests.

Unless you have a compelling reason (because for example if you are running 2 webservices [e.g. Apache and IIS] at the same time on the machine), it might be best to simply change your new virtual host to port 80. Snooping a bit, I saw on SO that you asked a similar question. If you're trying to redirect mobile clients to a different site (or your app, for example), you can user mod_rewrite based on the user-agent.

For example:

<VirtualHost *:80>
DocumentRoot /www/mainwebsite
ServerName foo.com
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
RewriteRule ^$ m.foo.com/ [L,R=302]

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/mobileapp
ServerName m.foo.com
# You might check for the USER_AGENT here and redirect to the main site if not found
</VirtualHost>


It's late and the above may be a bit off -- if this is helpful to you, perhaps someone can edit it to be more correct.

10% popularity Vote Up Vote Down


 

@Shanna517

The HTTP protocol uses port 80 by default. If you configure your web server to use a nonstandard port, then the port needs to be specified in the URL. There's no way to hide that.

In Apache, you can set the listening port in httpd.conf, e.g.:

Listen 127.0.0.1:80


This can however be overridden in the vhost config, e.g.:

<VirtualHost *:80>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme