Proxy Apache FastCGI - apache

I have a domain with a python django application and the request tracker software.
The goal of the post is to move the request tracker to the path "^/ ticket /*"
That's why the consideration is "mod_proxy_fcgi" (or does one rather use "mod_proxy_http"?).
Original working 000-default.conf code without proxy:
<VirtualHost *:80>
DocumentRoot /opt/rt4/share/html
Alias /NoAuth/images/ /opt/rt4/share/html/NoAuth/images/
ScriptAlias / /opt/rt4/sbin/rt-server.fcgi/
<Directory "/opt/rt4/sbin">
Require all granted
</Directory>
</VirtualHost>
Changed code with proxy settings (does not work):
<VirtualHost *:80>
ProxyPassMatch "^/ticket/*" "fcgi://localhost:80/opt/rt4/sbin/rt-server.fcgi/"
Alias /NoAuth/images/ /opt/rt4/share/html/NoAuth/images/
ScriptAlias / /opt/rt4/sbin/rt-server.fcgi/
<Directory "/opt/rt4/sbin">
Require all granted
</Directory>
</VirtualHost>
The proxy redirect returns HTTP code 503 "Service Unavailable" (http://localhost/ticket/).
Where am I wrong?

Related

Redirect http default port to an application on same port - CentOS 7

I have an installation of httpd on my server and a web application on it (/var/www/html/app). I want to when a user enter the IP of my server over HTTP (123.125.21.45:80) this redirects to my application on same port (123.125.21.45:80/app)
I have created and app.conf in /etc/httpd/conf.d/app.conf
<VirtualHost *:80>
DocumentRoot /www/html/app
ServerName 123.125.21.45
</VirtualHost>
And the result on the web browser is
http://123.125.21.45/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/app/
What am I doing wrong?
Please use below virtual host file and then try.
Note: make sure you are not using any redirection from .htaccess file.
<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerName 123.125.21.45
Redirect permanent / http://123.125.21.45/app/
<Directory /var/www/html/>
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>

(Apache) Forbidden 403 when accessing subdomain

I want to set up the subdomain "shop" on my Apache 2.2 server on Windows/XAMPP and it redirects to "index.html" if I enter "shop.localhost" as the URL but once I try to connect via my domain "sv443.net" it redirects to my document root ("/index.html" instead of "/shop/index.html"). Connecting to "sv443.net/shop/" works fine though and even redirects to "index.html".
I'm using Cloudflare to handle the DNS stuff and added these records (I cut off the IP address part):
This is my httpd-vhosts.conf:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs"
<Directory "c:/users/sv443/desktop/mamp htdocs">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost shop.localhost:80>
ServerName shop.localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs/shop"
<Directory "c:/users/sv443/desktop/mamp htdocs/shop">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
And this is my hosts.dat:
(only comments)
2.205.169.73 sv443.net
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost shop.localhost
Also I added this .htaccess file to the shop directory to redirect to the index.html if a 403 or 404 is encountered - removing this file doesn't fix my problem:
ErrorDocument 403 /shop/index.html
ErrorDocument 404 /shop/index.html
If someone tries to connect I get this error message in the Apache error.log:
AH01630: client denied by server configuration: C:/Users/Sv443/Desktop/MAMP htdocs/shop/.html
Thanks for any help!
If you can get content by explicitly specifying "/index.html" but not with "/", you should add DirectoryIndex index.html in your configuration, after loading mod_dir. This will define the default file to look for when it is not specified.
For your VirtualHost:
<VirtualHost *:80>
ServerName localhost
ServerAlias www.example.com
ServerAlias example.com
LogLevel debug
CustomLog "logs/example_access_log" combined
ErrorLog "logs/example_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
<VirtualHost *:80>
ServerName shop.localhost
ServerAlias shop.example.com
LogLevel debug
CustomLog "logs/shop_access_log" combined
ErrorLog "logs/shop_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
Apache decides which VirtualHost to use for the request based on the domain in the request. If it does not find a match, it uses the first one in the file (here localhost). Therefore you are not pointing to your "shop" sub-domain, unless you specify it in the VirtualHost for it, via ServerAlias ....

How apache2 can deny connections to a domain which is not hosted

I am hosting website iplocation.io on a cloud server. I found a domain https://chrissloey.com/index.php which opens my website within it.
Now from what I understand, chrissloey.com has pointed it A record to my server ip and my apache2 server is not denying connection to it and allow's to open iplocation.io website content like its own.
I want apache2 to deny connections to any other domain and only allow my own domain to server content.
Attached is apache conf file for iplocation.io
<VirtualHost *:80>
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
ServerName iplocation.io
ServerAlias www.iplocation.io
ErrorLog ${APACHE_LOG_DIR}/apache-error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName iplocation.io
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
SSLEngine on
SSLCertificateFile /path-to-csr
SSLCertificateKeyFile /path-to-key
SSLCertificateChainFile /path-to-ca
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
</IfModule
Looking at the two comments I think the combination makes most sense:
Configure httpd to respond with redirect (301) to all incoming requests. This could be done on the 'root' host.
Configure a virtualhost listening to your domain only, and this one would serve your real content only.
This will work unless the other site requests your content and then integrates it into their responses. But as you said someone else simply put up a DNS A record.

How to configure different Virtual Hosts based on apache + php_cgi and apache+mod_php?

everybody.
I have a Cent OS 6.6 server with Apache + mod_php site (site1.local). I need to configure second site (site2.local) with php_cgi. So, I created a user, gave him permissions on www-folder, configured site1 as mod_php, created a phpinfo.php. Also, I installed php-cgi,and try to configure virtual hosts, works only first site, on the second site is error:
the requested url /cgi-bin/phpinfo.php was not found onthis server.
That's my configs:
cat /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin webmaster#site1.local
DocumentRoot /var/www/wwwmaster/site1.local
ServerName site1.local
ServerAlias www.site1.local
ErrorLog logs/site1.local-error_log
CustomLog logs/site1.local-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#site2.local
DocumentRoot /var/www/wwwmaster/site2.local
ServerName site2.local
ServerAlias www.site2.local
ScriptAlias /cgi_bin/ /usr/bin/php-cgi/
Action php-cgi /cgi-bin
AddHandler php-cgi php
<Directory /usr/bin/php-cgi>
Allow from all
</Directory>
<Directory "/var/www/wwwmaster/site2.local/">
<FilesMatch "\.php">
SetHandler php-cgi
</FilesMatch>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
ErrorLog logs/site2.local-error_log
CustomLog logs/site2.local-access_log common
</VirtualHost>
What I've done wrong and how can I fix that?
You only have to uncomment the line that says NameVirtualServer *:80 in your apache config file.
If you want virtual server for more than one port, simply put as many NameVirtualServer *:[port number] in the apache config file as you need.

Why does port-based VirtualHost not work?

I'm trying to serve up two different Django apps on two separate ports. I have app1 on port 80 and app2 on port 8080. So what I'm expecting is that when I put example.com:80 into my browser, my request should get served up from app1, and when I put example.com:8080 into my browser, my request should get served up from app2. However, sometimes it will serve up my request from the wrong app. Then, after a few refreshes, it will sometimes switch. What's more, sometimes it will serve up from the correct app and then, after a few refreshes, switch to the wrong one. I know this isn't due to caching on the browser's end because I've also tried sending requests with curl from the machine and I get the same behavior. I can't understand why I'm getting this unexpected, nondeterministic behavior.
Here is my VirtualHost configuration:
<VirtualHost *:80>
ServerAlias *
ServerPath /app1/
WSGIScriptAlias /app1 /home/eyuelt/app1/app1/wsgi.py
Alias /app1/static /home/eyuelt/app1/staticfiles
<Directory /home/eyuelt/app1/app1>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app1/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Listen 8080
<VirtualHost *:8080>
ServerAlias *
ServerPath /app2/
WSGIScriptAlias /app2 /home/eyuelt/app2/app2/wsgi.py
Alias /app2/static /home/eyuelt/app2/staticfiles
<Directory /home/eyuelt/app2/app2>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app2/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
I suspect this might be the problem:
http://httpd.apache.org/docs/2.2/vhosts/examples.html
This is what you want: You have multiple domains going to the same IP
and also want to serve multiple ports. By defining the ports in the
"NameVirtualHost" tag, you can allow this to work.
One or both of these could be the problem: If you try using
without the NameVirtualHost name:port or you
try to use the Listen directive, your configuration will not work.
Server example:
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot /www/domain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot /www/domain-8080
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot /www/otherdomain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>