Installing a program to my server - invoice

Pictures shows that I put on terminal:
sudo vim /etc/apache2/sites-available/fusion_invoice.dev.conf
After that at sitepoint.com says that I need to copy paste below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/fusioninvoice
ServerName fusion.invoice.dev #change this setting according to your domain name
DirectoryIndex index.php
<Directory /var/www/fusioninvoice>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I do not know which path to change.
Help!

In the file you mentioned, the Apache config file, add the following code:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/fusioninvoice # <<< CHANGE THIS PATH TO THE ABSOLUTE PATH ON YOUR SERVER WHERE THE CODE IS STORED
ServerName fusion.invoice.dev #change this setting according to your domain name
DirectoryIndex index.php
<Directory /var/www/fusioninvoice> # <<< ALSO, CHANGE THIS PATH TO THE ABSOLUTE PATH ON YOUR SERVER WHERE THE CODE IS STORED. SAME AS ABOVE
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I hope it is clear now :)

Related

Permanent redirection of a dockerized ShinyApp with Apache2

I try to deploy a dockerized shiny app. For deploying and securising with Apache2, there is no problem. My app is available at the port 4001 for http and the port 5001 for https.
My problem is when I try to suppress the port 4001 or redirect permanently the port 4001 to the port 5001.
Here is my apache configuration :
<IfModule mod_ssl.c>
<VirtualHost *:4001>
ServerName mywebsite.com
ServerAdmin webmaster#localhost
Redirect permanent / https://mywebsite.com/deletepoint
# RedirectMatch permanent ^/(.*)$ https://mywebsite.com/$1
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/certificatefile.cer
SSLCertificateKeyFile /etc/ssl/certs/certificatekeyfile.key
</VirtualHost>
<VirtualHost *:5001>
ServerName mywebsite.com
ServerAdmin webmaster#localhost
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /deletepoint ws://localhost:4001/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /deletepoint http://localhost:4001/$1 [P,L]
SSLEngine on
SSLCertificateFile /etc/ssl/certs/certificatefile.cer
SSLCertificateKeyFile /etc/ssl/certs/certificatekeyfile.key
ProxyPreserveHost On
ProxyPass / http://localhost:4001/
ProxyPassReverse / http://localhost:4001/
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory "/var/www/html/obs-foncier">
Options +FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
</IfModule>
If someone has already had this configuration problem, or know how to do a good configuration, please help me. Thanks in advance.

Angular 5 deployment with Apache2

I am working with a project having its front-end in angular. I am having issue when deploying it to server. The project was deployed using jenkins and the project folder angProject1 was deployed in /var/www/html/dms folder.
The /etc/apache2/sites-available/dmsproxy.conf file have
ServerName dms.xxxxxx.com
DocumentRoot /var/www/html/dms/angProject1
I have added the .htaccessfile to /var/www/html/dms/angProject1:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
And /etc/apache2/sites-enabled/000-default.conf contains :
<Directory "/var/www/html/dms">
AllowOverride All
</Directory>
I can access the dms.xxxxxx.com page, but when I try for dms.xxxxxx.com/opendms etc, it is not working (ERROR:The requested url was not found). Tried adding # as dms.xxxxxx.com/#/opendms too, but it redirects to dms.xxxxxx.com file.
The base href in index.html is <base href="./">.
Thanks for the help!
I solved the issue. Changed the
<Directory "/var/www/html/dms">
AllowOverride All
</Directory>
inside the /etc/apache2/apache2.conf and now the application is reading the .htaccess file. Also my .htaccess is changed to:
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
Changed the base href to <base href = "angProject1"/>

How to configure a Dockerized GitLab CE on Ubuntu which is proxied with HTTPS by Apache2?

I am trying to configure my docker GitLab CE (latest) instance that works with an integrated letsnecrypt that is part of the docker, in order to authenticate it as HTTPS under a sub-domain that is proxied by an Apache 2.4.
The reason i want it to go through Apache is that In this environment there is a web page running which claims port 80, 443 etc. So, in order for me to have both, i have mapped docker's ports to 443:444 and 80:3000.
And via apache's virtual host naming i have the following configuration:
<VirtualHost domain.com:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost gitlab.domain.com:80>
ServerAdmin webmaster#localhost.com
ProxyPreserveHost On
ProxyPass "/" "http://public-ip:3000/"
ProxyPassReverse "/" "http://public-ip:3000/"
ServerName gitlab.domain.com
</VirtualHost>
<VirtualHost gitlab.domain.com:443>
ServerAdmin webmaster#localhost.com
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
ProxyPreserveHost On
ProxyPass "/" "http://public-ip:3000/"
ProxyPassReverse "/" "http://public-ip:3000/"
ServerName gitlab.domain.com
</VirtualHost>
What do you think is the best approach?

Apache + Passenger non-www to www => too many redirects

I am using phusion passenger to host a rails app at www.example.com. I want to tell apache to redirect example.com to www.example.com. The standard way seems to be using two virtual host configs. I am doing this, but I am getting a "too many redirects" error. Following is my config:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
...
</VirtualHost>
Thanks. I am using Passenger 3.0.11, Apache2.
We use a single virtual host config with a .htaccess file.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/public
<Directory /var/www/public>
AllowOverride all
Options Indexes FollowSymLinks MultiViews
</Directory>
</VirtualHost>
Then in your /var/www/public/.htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Apache: Serving assests via HTTP while site is running on HTTPS

We have our site running on HTTPS. Is there a way to accept HTTP request for URLs containing /public/? For all other HTTP requests they should be redirected to HTTPS.
I have RoR application running on apache + passenger.
EDIT
Since the assets (/public/) requests will explicitly be on HTTP, how about creating another VHOST to handle HTTP requests. And for any requests other than /public/ directly could be redirected to HTTPS? If we can go this way how can we set this up in VHOST for HTTP?
EDIT 2
I am sorry, I should have been elaborated this in first place. Here is our setup. There two separate applications. One is running on HTTPS (S) and other on HTTP (P). The app P fetches data (a full HTML page, call it page) from S and render to client. The CSS file used in page is located on 'S' so I need to HTTPS in CSS link. I want to use HTTP instead to refer the CSS.
You can use mod_rewrite and place a .htaccess file with the below contents in your DocumentRoot.
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
Rewritecond %{REQUEST_URI} .*/public/.* [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Rewritecond %{REQUEST_URI} !.*/public/.* [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
NameVirtualHost *:80
Listen 80
Listen 443
<VirtualHost *:80>
ServerAdmin username#somesite.com
DocumentRoot /pathto/DocumentRoot
ServerName domain.com
ErrorLog path/to/your-error_log
CustomLog path/to/your-access_log common
RewriteEngine on
RewriteBase /
Rewritecond %{REQUEST_URI} !.*/public/.*$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin username#somesite.com
DocumentRoot /pathto/DocumentRoot
ServerName domain.com
ErrorLog path/to/your-error_log
CustomLog path/to/your-access_log common
RewriteEngine on
RewriteBase /
Rewritecond %{REQUEST_URI} .*/public/.*$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#All the other directives pertaining to SSL add below
</VirtualHost>

Resources