17

I've been searching Google and have no had much success in finding an answer. I'm running a server on Ubuntu and I have programs installed that use various non-standard ports. Each one uses a different port, in my case they are 9090, 9091, 9092, 9093, and 9094. I set up an apache server and have a domain name that can now reach my server instead of having to type in my IP address. What I'm looking for is a way to create directories that can point to the different ports I've listed. I want something like:

https://www.mydomain.com/app1
https://www.mydomain.com/app2
http://www.mydomain.com/app3

Some of the ports are over SSL, some are not, I just put them in order (9090-9094) for ease of use on my part. I'd like to get the /app1 to point to SSL port 9090, /app2 to point to SSL port 9091, and /app3 to point to non-SSL port 9092. Is there a simple way to do that? I've tried adding ProxyPass and the like based on other posts but nothing has worked. Do I need to add a new site?

Also, if this involves editing files, which I expect it will, it would be greatly appreciated if you could list the default location of the file and where to add things. I kept seeing posts saying to add ProxyPass, so I just assumed it went inside of VirtualHost, but I wasn't entirely sure. Basically, I know very little about web server setup and I need to be treated as such.

I apologize for any incorrect tags and I appreciate the time you took to read the post and any help you can provide.

EDIT: For clarification, the applications are already accessible through https://www.mydomain.com:9090, etc. I would just like a way to use https://www.mydomain.com/appName to get to the same location/page published by those applications.

EDIT 2: From /etc/apache2/sites-available/default

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass /app1 https://localhost:9090/
    ProxyPassReverse /app1 https://localhost:9090/
</VirtualHost>
Serneum
  • 273
  • 1
  • 2
  • 6
  • 1
    Can you post the output of the configuration directives that you used to set this up? If they're inside a vhost, can you post the whole vhost? – Marcos Velazquez Jan 25 '13 at 20:48
  • 1
    Set what up? The ports? The ports are all set up through the UI of their respective programs and I'm looking for a way to avoid having to type in the ports when accessing each application on my server. I can dig through the applications to see what I can find, but the ports are usually just stored in a config.ini file – Serneum Jan 25 '13 at 20:55
  • 1
    No not that. I meant that, if you're using ProxyPass and the other things, you must have placed them inside of a vhost, right? If so, can you post the whole vhost content if possible? i.e. ` ServerName server.domain.com DocumentRoot /usr/local/apache/htdocs ` – Marcos Velazquez Jan 25 '13 at 20:59
  • 1
    I had undone most of my changes in order to get a clean slate before asking for help. I just added the /etc/apache2/sites-available/default file I have and I added the Proxy stuff at the end based on what I had seen at various other sites/searches – Serneum Jan 25 '13 at 21:06

1 Answers1

17

Make sure that the following apache modules are installed and loaded:

mod_proxy
mod_proxy_http
mod_ssl

You can check via running the following command as root(assuming httpd is in your $PATH)

httpd -t -D DUMP_MODULES

Afterwards, try changing your configuration to the following:

ProxyRequests Off
<Proxy *>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Proxy>
SSLProxyEngine on
ProxyPass /app1 https://localhost:9090
ProxyPassReverse /app1 https://localhost:9090

The proxy should now work if you visit http://localhost/app1 or http://mydomain.com/app1 assuming mydomain.com points to localhost.

  • 1
    Same issue as before, I have no idea how to install mod_proxy and a2enmod mod_proxy says that mod_proxy does not exist. I'll keep looking for how to get those 3 mods so that I can get things to work. That being said, I do have proxy, proxy_http, and ssl running right now. If those are what I need, then this solution still seem to not work. I get a Forbidden message which I assume might be related to that "Allow from 127.0.0.1" but I'm not entirely sure – Serneum Jan 25 '13 at 22:16
  • 1
    Side note, mydomain.com points to my external IP and not localhost. I've tried changing the localhost:9090 to my ip:9090 but with no success. Is the "Allow from" and the "https://localhost" next to the ProxyPass relative to the server or relative to what is trying to access it? – Serneum Jan 25 '13 at 22:23
  • 1
    Got it working by doing Allow from all temporarily. Downside is that no css, etc appears on the page, but that is whole separate issue that I will look at on my own. Thanks. – Serneum Jan 25 '13 at 23:07
  • 1
    To which configuration file do I need to add `ProxyRequests Off Order deny,allow Deny from all Allow from 127.0.0.1 SSLProxyEngine on ProxyPass /app1 https://localhost:9090 ProxyPassReverse /app1 https://localhost:9090` ? – kiltek Jan 07 '16 at 10:36
  • 2
    Page assets not showing might not be a separate issue. The ProxyPass directive here applies to document (app1) only. To Proxy app1 directory with all its contents, add trailing slashes. `ProxyPass /app1/ https://localhost:9090/` and the same for ProxyPassReverse if used. And secondly, add RewriteRule redirect: `RewriteRule ^/app1$ /app1/ [R]` as /app1 would not be proxied then. – papo Nov 01 '18 at 17:49