Apache Port Redirection - apache

I have some trouble concerning Apache Webserver 2.4.7. I want to redirect some pages to another port (doesn't matter which one, I choose 82). Therefore, I edited the VirtualHosts as follows:
<VirtualHost _default_:82>
DocumentRoot /var/www/html/hpc_test/web/trunk/
ServerName localhost
<Directory /var/www/html/hpc_test/web/trunk/>
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The redirection works fine but the new DocumentRoot does not. Some SSI commands are used assuming that /var/www/html/hpc_test/web/trunk/ is the DocRoot. Unfortunately, /var/www/html/ is considered as DocRoot for port 82.
Does any Apache expert can tell me if there's anything else I have to do? I studied the documentation and followed those instructions.
Cheers

First check if apache correctly listen in the port 82 :
netstat -laputen|grep 82
In your web-browser, do you use http://localhost:82 ?
Because you just listen to ServerName localhost, if you try with an other domain, apache going to redirecting in your default vHost

Related

How can I create different ports on Apache VirtualHosts

I'm trying to create VirtualHost for a different port number with below code, but when I try to access that port number "domain: port" I receive "ERR_CONNECTION_REFUSED" error on browser.
Steps, what I do
First editing http.conf, created for the related domain via Plesk
I am writing these codes
Restart Apache
Also I add that port number on httpd.conf. (Listen: port) but at this point I receive "Internal Server Error"
What do I use:
Plesk 12,
Apache/2.2.15 (Unix),
Ngnix (Reserve proxy)
<VirtualHost IP:8324>
DocumentRoot "/var/www/vhosts/httpdocs"
ServerName "domain:8324"
ServerAlias "www.domain.com"
ServerAlias "ipv4.domain.com"
UseCanonicalName Off
<Directory /var/www/vhosts/httpdocs>
DirectoryIndex index.php
Options +Indexes +FollowSymLinks +MultiViews +Includes
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
What am I missing? Thank you
I think you can do that using a custom template for a specific vhost.
You should check these two links. The might put you on the right track:
https://docs.plesk.com/en-US/12.5/advanced-administration-guide-linux/virtual-hosts-configuration/changing-virtual-hosts-settings-using-configuration-templates/example-changing-default-apache-ports.68800/
https://docs.plesk.com/en-US/onyx/advanced-administration-guide-linux/virtual-hosts-configuration/changing-virtual-hosts-settings-using-configuration-templates.68693/
Just so you know, any manual changes that you do in the httpd.conf file (from a ssh console for example, at the next plesk update or when you add/delete an account, they will be overwritten since Plesk is regenerating the httpd.conf file)

Configure Apache to run website off of port-enabled IP address

To be perfectly honest, I'm not even sure if this is doable...
I've configured my vhosts file in /etc/apache2/sites-enabled which you can see here:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster#localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
DirectoryIndex index.php index.html
<Directory "/home/wiki/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wiki_error.log
CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined
</VirtualHost>
for a digitalocean droplet given at the IP listed in the above hosts file. This droplet has absolutely nothing on it except for the wiki user in /home/ plus the required php, mysql/mariadb, apache stuff.
What I want to be able to do is to go to 159.203.171.140:8080 and see my site without having to purchase a useless domain name.
I'd really appreciate some help with this one.
If you have only one website on the droplet, then you don't need to set up a virtual host. You can use the 000-default.conf, no need for a2ensite.
You do not need the ServerName, which won't work with the IP as a name, you also don't need the IP address in the VirtualHost directive.
So, instead of this:
<VirtualHost 159.203.171.140:8080>
ServerAdmin webmaster#localhost
ServerName 159.203.171.140:8080
DocumentRoot "/home/wiki/public_html"
...
You can use this in your 000-default.conf file
<VirtualHost *:8080>
DocumentRoot "/home/wiki/public_html"
...
The rest of the directive stays as you have it.
Also, one note, if you are using port 8080, then you need go to /etc/apache2/ports.conf and set the Listen to 8080 (restart Apache after doing this).

Apache Passenger handle 'www' in url

I've an application deployed to EC2 using passenger and apache2.
I've registered a domain (not with AWS) and have two 'A' records pointing to my instance's elastic IP
appname.com.
*.appname.com.
In my apache2.conf file (below), I've got ServerName appname.com
The application is working perfectly when you type appname.com into a browser. But if you put www.appname.com into the browser, you just get the default apache page.
Does anyone know what I put in ServerName to handle both? I've tried adding another ServerName line under the first but it doesn't work.
Thanks for looking
/etc/apache2/apache2.conf
<IfModule mod_passenger.c>
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-5.0.6
PassengerDefaultRuby /usr/bin/ruby1.9.1
</IfModule>
<VirtualHost *:80>
ServerName appname.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/ubuntu/projects/appname/public
ErrorLog /home/ubuntu/projects/appname/log/error.log
RailsEnv development
<Directory /home/ubuntu/projects/appname/public>
# This relaxes Apache security settings.
AllowOverride all
Require all granted
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
I solved it thanks to this post (shame you can't thank on the other stack sites using your stackoverflow reputation)
Under
ServerName appname.com
you put
AliasName www.appname.com
or even better
AliasName *.appname.com

Apache 2 Test Page

I dont know why I see this Apache test page when I've configured my virtual host to point to my project?
Server settings
<VirtualHost *:80>
ServerName malltomobiledev.com
DocumentRoot /home/dcms/public/html/dcms/app/web
<Directory "/home/dcms/public/html/dcms/app/web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Apache restarted fine, so it was access the folders fine.
My host file
Ip malltomobiledev.com
Any ideas guys?
If you're using apache 2.2, make sure you have NameVirtualHost *:80 set in your main apache config file, otherwise apache will use the default virtual host, which points to the test page.
You can check the configured virtual hosts using apachectl -S

Rackspace server and CakePHP webroot help

I am moving my cakephp website from my old server to rackspace. I can load my website fine but all the CSS and JS is broken. I'm not sure if it's a Cake setting I'm over looking or a Rackspace setting I'm over looking. I have my cake install in
/var
/www
/rp
/app
/cake
etc
etc
This is the error I see whenever I restart apache. Something isn't lining up. Please, let me know if I need to provide any other information to help resolve this issue. Thanks!
Restarting web server apache2
Warning: DocumentRoot [/var/www/app/webroot] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using x.x.x.x for ServerName
... waiting Warning: DocumentRoot [/var/www/app/webroot] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using x.x.x.x for ServerName
...done.
If the DocumentRoot is not specified in apache2.conf, then it defaults to /var/www
However, I usually like to put it in my vhosts file. Make sure your vhost file is included. For example:
Include /private/etc/apache2/extra/httpd-vhosts.conf
An example of a vhost file is as follows:
NameVirtualHost *
<VirtualHost *>
ServerName www.abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/rp/app/webroot/
ErrorLog /var/log/apache2/abc.log
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>