Angular using apache with google analytics - angularjs

Okay ive been attempting this for days without any results and i really hope that some of you can help me.
I have problems with google not indexing my website meaning it cannot see the content of my website.
My website is an angular application.
So i saw this post ng-newletter saying that i could use apache so my configs are as follow:
$ a2enmod proxy
$ a2enmod proxy_http
Which enables proxy
Then i have edited my virtualhost with the following:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAdmin webmaster#localhost
ServerName www.mydomain.dk
ServerAlias mydomain.dk
DocumentRoot /var/www/mydomain/
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$
RewriteRule ^(.*)$ /snapshots/%1? [NC,L]
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/mydomain/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Now when i attempt to run the google-bot-simulator i get some odd response:
No matter which url i go to it tells me that it has redirected back to index
and i am now unable to go to www.mydomain/subsite without getting a 404
So what am i doing wrong?
Answer from google
HTTP/1.1 301 Moved Permanently
Date: Thu, 17 Sep 2015 13:13:27 GMT
Server: Apache/2.4.7 (Ubuntu)
Location: http://mydomain.dk/products
Content-Length: 315
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at www.mydomain.dk Port 80</address>
</body></html>

Related

Certbot not working correctly for subdomain

I have a VPS server with SSL Certbot, in Debian with apache, but not working correctly for subdomains. When accessing my subdomain with http://, it goes directly to the directory that I configure.
But, when accessing with https:// protocol, it goes directly to the root directory, that is /var/www/html.
I am new to the VPS servers, and I not know what's the problem.
This is my /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =app.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com [OR]
RewriteCond %{SERVER_NAME} =www.mysite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:80>
ServerName app.mysite.com
DocumentRoot /var/www/html/app
</VirtualHost>
Thanks for your time
Your configuration sample is missing the configuration for https / port 443.
From your http configuration
<VirtualHost *:80>
ServerName app.mysite.com
DocumentRoot /var/www/html/app
</VirtualHost>
So you should change the DocumentRoot of your SSL-configuration file also to DocumentRoot /var/www/html/app. Probably this file is called 000-default-ssl.conf.
Usually it is a good idea to create is own files and use them instead of the default ones. Especially when you do a dist upgrade and configuration files change this is much less hassle, because when changing default files you get a dialog and have to decide which version you want to keep. Selecting the wrong and you have to restore your changed config-file from a backup.

How to enable a web server and webdav server simultaneously on Raspberry Pi 3?

My Pi version is:
pi#raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Apache version installed on Pi:
pi#raspberrypi:~ $ apache2 -version
Server version: Apache/2.4.25 (Raspbian)
Server built: 2019-10-13T15:43:54
The web-server is successfully serving a WordPress site on http://localhost. I am trying to enable WebDAV based access simultaneously. I have following two sites configured:
pi#raspberrypi:/etc/apache2/sites-available $ pwd
/etc/apache2/sites-available
pi#raspberrypi:/etc/apache2/sites-available $ cat 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
pi#raspberrypi:/etc/apache2/sites-available $ cat 001-default.conf
DavLockDB /usr/local/apache2/var/DavLock
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/web1/web/
<Directory /var/www/web1/web/>
DAV On
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /webdav /var/www/web1/web
<Location /webdav>
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/web1/passwd.dav
Require valid-user
</Location>
</VirtualHost>
I can see the two sites loaded:
pi#raspberrypi:/etc/apache2/sites-available $ pwd
/etc/apache2/sites-available
pi#raspberrypi:/etc/apache2/sites-available $ apachectl -D DUMP_VHOSTS
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/001-default.conf:2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
*:* 127.0.1.1 (/etc/apache2/sites-enabled/001-default.conf:3)
pi#raspberrypi:/etc/apache2/sites-available $
However, cadaver cannot reach the webDAV:
pi#raspberrypi:/etc/apache2/sites-available $ cadaver http://localhost/webdav/
Could not access /webdav/ (not WebDAV-enabled?):
405 Method Not Allowed
Connection to `localhost' closed.
dav:!>
What am I doing wrong?

setup apache reverse proxy from localhost to domain.com/etherpad

Good evening,
I am trying to set up my apache2 reverse proxy
(following https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy)
for etherpad lite
(following https://www.howtoforge.com/tutorial/ubuntu-etherpad-editor-server-installation/, except for the nginx part).
I use http->ssl redirection. Since I use letsencrypt I can only access domain.com and not etherpad.domain.com (at least firefox won't let me and I want to avoid changing that certificate each time I add a new site). So I would like to access my etherpad just as I do access my other sites: domain.com/etherpad. However I always get a 404 trying to get to the site. Looking at a working example, in my nextcloud.conf file I have a line saying:
Alias /nextcloud /local/path/to/nextcloud
However the etherpad reverse proxy virtual host file looks entirely different, the key difference is etherpad not having a local folder but only a mysql database. (Please correct me if this is wrong)
So I tried changing the ssl example from the second link to the following, but it does not work. Please understand that I changed domain name and some internal paths, but "apache2ctl configtest" succeeds and the service is running without error.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName randomisedDomain.com/etherpad
# SSL configuration
SSLEngine on
# If you hold wildcard certificates for your domain the next two lines are not necessary.
SSLCertificateFile "/working/path/to/fullchain.pem"
SSLCertificateKeyFile "/working/path/to/privkey.pem"
ProxyVia On
ProxyRequests Off
ProxyPreserveHost on
<Location />
AuthType Basic
AuthName "Welcome to the randomisedDomain.com Etherpad"
AuthUserFile /working/path/to/etherpad.passwd
#AuthGroupFile /path/to/svn.group
Require user etherpad
ProxyPass http://localhost:9001/ retry=0 timeout=30
ProxyPassReverse http://localhost:9001/
</Location>
<Location /socket.io>
# This is needed to handle the websocket transport through the proxy, since
# etherpad does not use a specific sub-folder, such as /ws/ to handle this kind of traffic.
# Taken from https://github.com/ether/etherpad-lite/issues/2318#issuecomment-63548542
# Thanks to beaugunderson for the semantics
RewriteEngine On
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:9001/socket.io/$1 [P,L]
ProxyPass http://localhost:9001/socket.io retry=0 timeout=30
ProxyPassReverse http://localhost:9001/socket.io
</Location>
<Proxy *>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Proxy>
</VirtualHost>
Any help for rerouting the localhost domain to randomisedDomain.com/etherpad is greatly appreciated !
Best regards
MAPster

The requested URL /< was not found on this server. on Nagios core Ubuntu 16.04

I have an Ubuntu 16.04 server running nagios3 from the apt repo.
I get the message The requested URL/< was not found on this server
The config file in etc/apache2/sites-available which is soft linked to sites-enabledconfig;
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName monitor.server.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/server.com.bundle.pem
SSLCertificateKeyFile /etc/ssl/private/server.com.key
SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt
ServerName monitor.novarumcloud.com
DocumentRoot /usr/share/nagios3/htdocs
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3/images /usr/share/nagios3/htdocs/images
Alias /images /usr/share/nagios3/htdocs/images
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
Alias /stylesheets /etc/nagios3/stylesheets
Alias /nagios3/js /usr/share/nagios3/htdocs/js
<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
Options FollowSymLinks
DirectoryIndex index.php index.html
AllowOverride AuthConfig
Order Allow,Deny
Allow From All
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios3/htpasswd.users
require valid-user
</DirectoryMatch>
<Directory /usr/lib/cgi-bin/nagios3>
Options +ExecCGI
</Directory>
Why is this happening? I'm sure it's probably a simple config error on my part. I have SSL certificates installed and only port 443 open too

Apache2 Ubuntu 12.10 Only Default Virtual Host is recognized

I've ran into this problem before with other flavors of Linux and typically it's something dumb but I think I've ruled out all those possibilities. I an using multiple virtual hosts on apache2 Ubuntu 12.10. As per Ubuntu default setup:
[ports.conf]
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Apache2.conf is ubuntu default and loads ports.conf.
I have two virtualhosts
<VirtualHost *:80>
ServerName *.staging.mydomain.com
Options -Indexes FollowSymLinks
UseCanonicalName Off
DocumentRoot /var/www/staging/app/application/current/app
ErrorLog "/var/log/error.log"
CustomLog "/var/log/custom_error.log" common
<ifModule env_module>
SetEnv PHP_ENV staging
</ifModule>
<Directory />
AllowOverride none
</Directory>
<Directory "/var/www/staging/app/application/current/app">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName *.devtest.mydomain.com
Options -Indexes FollowSymLinks
UseCanonicalName Off
DocumentRoot /var/www/devtest/app/application/current/app
ErrorLog "/var/log/error.log"
CustomLog "/var/log/custom_error.log" common
<ifModule env_module>
SetEnv PHP_ENV develop
</ifModule>
<Directory />
AllowOverride none
</Directory>
<Directory "/var/www/devtest/app/application/current/app">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</Directory>
</VirtualHost>
A request to somevalue.devtest.mydomain.com resolves to the same document root as somevalue.staging.mydomain.com. If I flip the order the VirtualHosts are declared in then this works in reverse; a request to somevalue.staging.mydomain.com will resolve to the same document root as somevalue.devtest.mydomain.com. No matter what I've tried, I cannot get both hosts to work at the same time. I have this working locally on WAMP and had this same issue but it was simply a misplaced NameVirtualHost *:80 that made it work. Moving the Listen and NameVirtualHost out of ports.conf into apache2.conf and removing the Include for ports.conf does not help. Apache generates no errors. Log level is set to debug.
And because I know you'll ask, yes I have enabled these sites using a2enmod. Yes, I have rebooted apache. I've gone so far as to reboot the server entirely. If I enable the default virtualhost that comes with ubuntu $sudo a2enmod default then it will catch all requests for both somevalue.devtest.mydomain.com and somevalue.staging.mydomain.com.
The virtual hosts are enabled and resolving $sudo apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server *.staging.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:19)
port 80 namevhost *.staging.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:19)
port 80 namevhost *.devtest.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:51)**strong text**
And finally, the requests resolve on the server curl -Lv http://test.staging.mydomain.com
* About to connect() to test.staging.mydomain.com port 80 (#0)
* Trying 1.1.1.1...
* connected
* Connected to test.staging.mydomain.com (1.1.1.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.27.0
> Host: test.staging.mydomain.com
> Accept: */*
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Date: Tue, 05 Mar 2013 02:22:28 GMT
< Server: Apache/2.2.22 (Ubuntu)
< X-Powered-By: PHP/5.4.6-1ubuntu1.1
< Vary: Accept-Encoding
< Content-Length: 18
< Content-Type: text/html
<
* Connection #0 to host test.staging.mydomainy.com left intact
<pre>staging</pre>* Closing connection #0
I've removed the IP and domain but it's definitely resolving properly. Everything on the servers run fine and in fact I didn't even notice the issue until I was on the staging environment and noticed data being updated on the devtest domain instead of staging.
I normally do not ask for any help on here and I've scoured the web and Stack Overflow alike. This does not seem to be a problem with incorrect port names, not declaring ServerName in the VirtualHosts, or not declaring the NameVirtualHost *:80 or Listening on the correct port. I'm completely stumped. Also, this same configuration works on an RPM based version of Linux.

Resources