Apache server-status error 403 Forbidden - http-status-code-403

I’ve the done below following steps to enable Apache server status in httpd.config configuration.
LoadModule status_module modules/mod_status.so
Virtual host:
<VirtualHost *:20443>
ServerName dev-server.com
<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from all
Allow from all
</Location>
</VirtualHost>
ExtendedStatus On
I'm getting error accessing server status screen.

Related

Apache ReverseProxy not working with Node and SSL

I'm trying to setup my app on HTTPS on a web server. I have a valid certificate that is installed on my InMotion host using AutoSSL. I have the node app running on my Centos server on port 3000 and my apache SSL server running on port 443. To route requests made to my website, I am attempting to create a reverse-proxy. I made a file called default-site.conf which is stored in /etc/http.d/conf.d and has the following contents:
<VirtualHost _default_:443>
SSLProxyEngine on
ServerName example.com
ServerAlias www.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
ServerAdmin info#example.com
DocumentRoot /home/USER/my-app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /home/USER/ssl/certs/certificate.crt
SSLCertificateKeyFile /home/USER/ssl/keys/certificate.key
ProxyPass / https://example.com:3000/
ProxyPassReverse / https://example.com:3000 /
<Directory "/home/USER/my-app/public">
AllowOverride All
</Directory>
</VirtualHost>
I will emphasize that the app is accessible at http://example.com:3000 (insecure) but when I attempt to go to https://example.com (secure) I get my blank index.html with a 404 error:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (index.js, line 0)
I managed to fix this issue by completely simplifying my config to the following two lines:
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
This may not be the most flexible approach but it reroutes the traffic the way I need it to be routed, so for my purposes, it works.

How to access website from apache2 (linux from GCP) from other port than 80?

I want to host a WordPress website on Google Cloud with Linux Instance.
There is already running website on port 80 and I want my new site to be hosted on any port other than 80.
I have changed following ports.conf and mywebsite.conf to achieve this
/etc/apache2/ports.conf
Existing Code
Listen 80
New Code
Listen 80
Listen 8080
I have created following file with VirtualHost
/etc/apache2/sites-available/mywebsite.conf
with Code
<VirtualHost *:8080>
ServerAdmin adminemail#gmail.com
DocumentRoot /var/www/mywebsite.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mywebsite.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
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
</VirtualHost>
After making these changes i just ran some commands as follows
$sudo a2ensite mywebsite.conf
$service apache2 restart
But when I hit my websites url as http://IPAdressOfServer:8080/ server is returning ERR_CONNECTION_TIMED_OUT.
What exactly I will have to do to make this correct?
You have to open the firewall port 8080 from your Google Project console. See this link: https://console.cloud.google.com/networking/firewalls/list?project=[your-project-id]. Replace your-project-id with the id of your Google Project

403 Error when running perl script in apache

I am trying to test perl scripts through localhost. I configured apache to allow perl scripts to be run from /usr/lib/cgi-bin (or so I thought). Whenever I go to localhost/cgi-bin/script.pl I get a 403 Forbidden error. Here is my apache conf file.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/cgtopher/public_html/
<Directory /home/cgtopher/public_html/>
Options FollowSymLinks Indexes
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
#cgi-bin
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI FollowSymLinks
Order allow,deny
Require all granted
</Directory>
ErrorLog /home/cgtopher/.apache/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
In my error log I keep getting this:
[Sat Sep 05 10:30:12.565510 2015] [access_compat:error] [pid 10918] [client 127.0.0.1:60699] AH01797: client denied by server configuration: /usr/lib/cgi-bin/hello.pl
You have Order allow,deny, which will reject the request unless at least one Allow directive passes.
You have no Allow directive (except for Directory /home/cgtopher/public_html/, which does not cover the cgi-bin directory).
(Add Allow from all to the cgi-bin directory?)

Is it possible to use node.js server without having the Port number appear in the URL.

I have a VPS using apache on port 80, but want to use node.js for a subdomain, without the port node will be using appear in the address bar.
Yes it is possible
In your apache virtual host file configure with the following:
<VirtualHost *:80>
ServerName subdomain.myapp.com
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ProxyPreserveHost on
</VirtualHost>
You should have
NameVirtualHost *:80

Run a NodeJS app with Apache

I have a ubuntu server running a few apache websites. I want to run a nodejs app on the same server. I have the app running on the server now out of port 3000 (www.example.com:3000) no problems there.
I now want to direct a new domain to the nodejs app with my existing apache setup. Below is an example of the config i'm running however it's pointing to a folder. What i require is the config that points to the app's port. And any extras that I maybe missing.
<VirtualHost *:80>
ServerAdmin spam#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>
First of all, you should to install mod_proxy and mod_proxy_http.
Then you can use something like the following configuration:
<VirtualHost *:80>
ServerAdmin spam#example.com
ServerName example.com
ServerAlias www.example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>

Resources