How to configure phabricator with a bare domain url? - apache

I'm trying to run phabricator on my home server. The last thing I struggle with is to use phabricator with a bare url. I've set up a virtual host (apache 2.4) using a seperate port for phabricator and added the required rewrite rules:
<VirtualHost *:81>
DocumentRoot /var/www/html/phabricator/phabricator/webroot
RewriteEngine on
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
<Directory "/var/www/html/phabricator/phabricator/webroot">
Require all granted
</Directory>
</VirtualHost>
Unfortunately, phabricator demands a non-root url. Any ideas?
I get the following error message:
User moodboom found a solution but did not post the answer at how-to-configure-phabricator-with-a-non-root-url.

It doesn't look like it demands a non-root URL from the post you pointed to. It looks like the reverse, it demands a root URL. As quoted in the answer you mentioned:
You can either install Phabricator on a subdomain (like
phabricator.example.com) or an entire domain, but you can not install
it in some subdirectory of an existing website.

Since there wasn't any easy way to solve this, I hat to set up a local DNS server (dnsmasq) to get rid of this problem. Manually changing the host file on every single client is possible but too tedious and error prone. Dnsmasq on the other hand was easy to setup on ubuntu 16.04 and will keep my local network a bit more organized.
Cheers,
O.Schmitz

Related

Using .htaccess to point absolute page links to directory instead of root domain

My local development web server has all my different project folders, for example:
https://localhost/project1
https://localhost/project2
Due to dynamic content, some of my projects require absolute links, such as /images/example.jpg - when they are uploaded to my web server, under their appropriate domain they work perfectly, for example domain.com/images/example.jpg
However on my local server they do not, because they point to localhost/images/example.jpg (obviously), however I need the root directory to be viewed as ./project1 so I need the link to be interpreted as localhost/project1/images/example.jpg
My current solution is I have this in my root .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /project1/$1 [L,QSA]
However this only lets me rewrite the links for one dynamic project folder at a time, which is problematic if I want to jump between projects.
How can I do this from .htaccess in the project folder so I can develop on my local server with ease without having to switch directories in the root .htaccess file?
Edit: with the help from arkascha I want to further clarify my question:
With .htaccess I would like to check if a file/directory is existent in the root directory (as seen in my example), if is not, I would like it to look for the file in the directory of the referrer (the first directory after root).
Based on your comments to the question this probably is what you are looking for:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https://[^/]+/([^/]+)/
RewriteRule ^/?images/ /%1%{REQUEST_URI} [END]
You can implement such rules in the http server's host configuration, or, if you have no access to that, you can use a distributed configuration file (".htaccess"), if you have enabled the consideration of such for that http host ...
Considering the clarification you made in your question after I offered my first answer, I would like to bring my first suggestions to notice again: using different host names. To me this sounds like the more promising approach to your situation.
You can use different hostnames locally without much effort. And if this only is about your local development environment anyway, then you also don't need to care about valid ssl certificates.
You just need to take care that a name resolution for such host name succeeds. All operating systems offer means for that, but the details obviously differ slightly. Unless you made really surprising changes to your local name resolution setup you should have a "hosts" file in your system where local host names can be registered in a static manner along with the address those names should get resolved to. That is effective, easy to setup and solves your issue.
Given that you can define a local host for each of your projects. Thus requesting these hosts just like your projects would get requested in production. This way your development setup stays much closer to the actual production setup you implement your projects for.
This would be an example for such a "hosts" file, here on taken from a typical Linux based system:
# Host addresses
127.0.0.1 localhost
127.0.1.1 bragi
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
You can simply add entries there using any plain text editor, for example you could append:
127.0.0.1 project1
127.0.0.1 project2
All that is left is to setup separate virtual hosts for those projects inside your http server:
<VirtualHost *:80>
ServerName project1
LogLevel notice
ErrorLog ${APACHE_LOG_DIR}/project1/error.log
CustomLog ${APACHE_LOG_DIR}/project1/access.log combined
DocumentRoot /var/www/hosts/project1
<Directory /var/www/hosts/project1>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName project2
LogLevel notice
ErrorLog ${APACHE_LOG_DIR}/project2/error.log
CustomLog ${APACHE_LOG_DIR}/project2/access.log combined
DocumentRoot /var/www/hosts/project2
<Directory /var/www/hosts/project2>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That is all you need to request your local http server using different host names for different projects:
http://project1/foo
http://project2/bar
You could even use the https protocol locally using a snake oil certificate, you'd have to accept that certificate once for every project then in the browser used for testing.
The bottom line:
You use a host name per project, just as you do in production. This keeps your local development setup much closer to the actual production setup. You don't need any fancy rewriting rules.
I personally chose to include common, repeated configuration options for those virtual hosts in a shared configuration file I include in those host definitions above. But that is a question of personal choice, there are endless options, obviously. The documentation of the apache http server and all its glorious modules will answer all questions about that. That documentation is of excellent quality and comes with great examples, as typical for OpenSource projects.

virtual host settings for typo3

DocumentRoot "C:/xampp_7/htdocs/BackupForEdow/Eddddddddd"
<Directory C:/xampp_7/htdocs/BackupForEdow/Eddddddddd>
AllowOverride All
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond {REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
</IfModule>
</Directory>
Is this correct for a typo3 project?
I am not able to access the frontend of typo3 but my backend works correctly. The front-end shows an internal server error.
Please help me to create the virtual host.
The vhost really does depend on other things: For example if you use the shipped .htaccess, you don't need the rewrite statements.
Copy the _.htaccess from the TYPO3 source to .htaccess in your document root for that.
About errors in general: As already recommended, look in the Apache (or php) error logs. Also look in the TYPO3 system log ("Log" in the Backend).
About the certificate error: You need to set up an SSL/TLS certificate if you want to be able to access your website via https://. This is not a TYPO3 specific thing. You may want to consult other resources, e.g. search on stackoverflow.
Perhaps this helps.
Also, check if you can load your webpage via http://
For ssl in general you need these things:
Create a signed certificate. Your hoster should be able to help you with that. If you are setting up your TYPO3 installation on your desktop PC, you can skip that part for now and override the error message in the browser. For a public website you should always setup your certificates correctly, though.
Make sure the Apache ssl modules are enabled. I don't know enough about Xampp to help you there.
Create and enable a vhost file for ssl / port 443. Look for an existing example ssl vhost files in the sites-available directory, e.g. default-ssl.conf or search for examples online
Having a not correct server name in the certificate should usually not lead to a 500 error. It should generate a warning in the browser.

Apache webserver rewrite all URL's excluding some

I'm using apache httpd v2.2 server as a frontend proxy for our actual tomcat web server which hosts the Java web application.
I want to forward all urls received by apache webserver other than those having the prefix /product to tomcat.
I've tried the following set up in httpd.conf but it' doesn't seem to work
<VirtualHost *:6111>
ServerName localhost
RewriteEngine on
RewriteRule !^(/product($|/)) http://localhost:1234/$1
Alias /product /opt/productdoc
</VirtualHost>
I tried to follow Redirect site with .htaccess but exclude one folder but was not successful
Basically all http://localhost:6111/product urls should serve from hard drive (using alias)
Any other url should be forwarded to http://localhost:1234/<original-path>
You probably want to use something like mod_jk http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html.
There are a ton of examples and tutorials and it should be pretty simple to setup and install. Now that you know the name of the connection technology, you should probably be able to find more information.
Using modjk also allows you to secure your tomcat server and keep the public off of it.

Apache always get 403 permisson after changing DocumentRoot

I'm just a newbie for Apache. I just installed apache 2.2 on the FreeBSD box at my home office. The instruction on FreeBSD documentation is that I can change the DocumentRoot directive in order to use the customized directory data. Therefore, I replaced...
/usr/local/www/apache22/data
with
/usr/home/some_user/public_html
but something is not right. There's index.html file inside the directory, but it seems that apache could not read the directory/file.
Forbidden
You don't have permission to access / on this server.
The permission of
public_html
is
drwxr-xr-x
I wonder what could be wrong here. Also, in my case, I am not going to host more than one website for this FreeBSD box, so I didn't look at using VirtualHost at all. Is this a good practice just to change the DirectoryRoot directive?
Somewhere in the apache config is a line like:
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/local/www/apache22/data">
You must change this path too, to make it work. This directive contains for example:
Order allow,deny
Allow from all
Which give initial user access to the directory.
one possibility that comes to mind is SELinux blocking web process from accessing that folder. If this is the case, you would see it in selinux log. You would have to check the context for your original web root with:
ls -Zl
and then apply it to your new web folder:
chcon whatevercontextyousaw public_html
Or, instead, if its not a production server that requires security (like a development machine behind a firewall), you might want to just turn selinux off.
Just one idea. Could be a number of other things.

Multiple domains on apache server

First a quick disclaimer, I'm not a 'server guy' or a 'unix pro' or anything like that, I'm a web programmer who got stuck doing server works since I ran linux (ubuntu) on my netbook.
I'm trying to set up an apache server running on Debian to automagically serve multiple domains, each domain needs to have its own directory in /var/www.
Since this is the last thing I do for this company I really need it to be easy for my successor (who is even more a beginner at servers than I am), to create more domains without having to muck around with ssh or /etc/apache2/sites-available, so what I'm looking for is basically any magic mumbo-jumbo in default (or apt-get, or conf.d) that makes the server start serving any domain that has a matching folder in /var/www they will ofcourse have to initiate domain transfers the usual way.
I have no problem setting up domains individually.
Ick... hope the above makes sense to someone.
To serve multiple domains from Apache, you'll need Apache Virtual Hosts. You can start serving any domain that has a matching folder in /var/www" with Apache Virtual Hosts using mod_vhost_alias.
The following configuration will take the fully-qualified domain name (like www.example.org) and use it as the variable '%0'. So, to serve out 'www.example.org', you create a directory at /var/www/www.example.org/docs , and place your HTML content there. Your Cgi script will go in /var/www/www.example.org/cgi-bin/
<VirtualHost 192.168.1.100:80>
# get the server name from the Host: header
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/docs
VirtualScriptAlias /var/www/%0/cgi-bin
</VirtualHost>
Then, point 'www.example.org' to '192.168.1.100', and Apache will happily serve that Virtual Host.
Untested Code with flavor of Ubuntu
sudo a2enmod rewrite
vi /etc/apache/sites-enabled/000-default
NameVirtualHost *
<VirtualHost *>
DocumentRoot /var/www/
RewriteEngine On
RewriteRule ^(.*)$ %{HTTP_HOST}/$1
</VirtualHost>
sudo /etc/inid.d/apache2 restart