Category Archives: web

Gogs.io running on subdomain with port

I'm trying to run Gogs.io on an apache webserver along with a standard website, and I'm trying to have Gogs.io used on a subdomain rather than using my standard domain with a port.

Gogs.io runs on port 3000, and I want the url to be

http://gogs.example.net/

Rather than

http://example.net:3000/

Both my public IP with port and example.net:3000 work, but when trying to use gogs.example.net, I always get an AT&T DNS Error Assist page. I'm not sure what I'm doing wrong, as I had it working earlier until I tried to change the name of the subdomain in my apache config, but I changed it back when I started having issues, to no luck.

Here is my Apache config for the page:

<VirtualHost *:80>
   ServerName gogs.example.net
   ProxyPreserveHost On
   ProxyPass / http://example.net:3000/
   ProxyPassReverse / http://example.net:3000/
</VirtualHost> 

This may be impossible, but any help would be greatly appreciated!

.htaccess not working with WWW

centOS 7, apache2, mod_rewrite enabled

httpd configuration:

<VirtualHost *:80>
    ServerName domain.com.au
    ServerAlias www.domain.com.au
    CustomLog /home/domain.com.au/logs/access.log common
    DocumentRoot /home/domain.com.au/www
    ErrorLog /home/domain.com.au/logs/error.log
    ServerAdmin [email protected]

    AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
    AddType application/x-httpd-php-source .phps

    <Directory /home/domain.com.au/www>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost> 

.htaccess works fine if you go without www. What could be the reason?

Thank you.

Htaccess redirect http to https and www to non-www doesn’t work

A website I'm working on needs to be redirected from http to https, we installed a certificate, and from www. to non-www. Since I'm not a star in .htaccess I looked up the right code on the internet and I found this:

RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ http://website.nl [L,NE,R=301]

RewriteCond %{HTTPS} off
RewriteRule ^ https://website.nl [L,NE,R=301]

also tried

RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://website.nl%{REQUEST_URI} [R=301,L,NE]

It should work, the www. to non-www https works, the second statement gives me an error when I create an error, but doesn't give me the result I want. I ran it through an online tester which says it should be fine this way. I've been looking for other versions of it, I used looking at the port, added the ssl check, nothing seems to work. What am I doing wrong?

How to block a specific website browser agent?

Lately i'm facing some issues with a data mining bot, extracting data from my website everyday at certain hours of the day. This will not only waste my bandwidth but also giving wrong data to my google analytics.

They usually use amazonaws IPs to enter however lately they've switched to other host.

What remains static is that they use the same user agent. is there a way to block using useragent? This is because i've tried it but it failed. Hopefully i can get a light out of this.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu HeadlessChrome HeadlessChrome Safari/537.36
RewriteRule .* - [R=503,L]

Access to subdomain on Apache Webserver with HTTPS

Right, I've been trying every code i could find on this page regarding this subject. Nothing works perfect.

Code now (tried so many, some created problems on mobile too)

    RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule (.*) https://www.example.com/$1 [L,R,NE]

# rule for removing www on sub domains
#RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.example\.com)$ [NC]
RewriteRule ^(.*)$ https://sub\.example\.nl/$1 [R=301,L]

# rule for forcing www on main domain
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Chrome

http://example.com -> https://www.example.com -> works

http://www.example.com -> https://www.example.com -> works

https://example.com -> https://www.example.com -> works

http://sub.example.com -> https://sub.example.com -> works

http://www.sub.example.com -> https://sub.example.com -> works

https://www.sub.example.com -> ""security fail **Does not work**

IE

http://www.sub.example.com -> ""security fail **Does not work**

https://www.sub.example.com -> ""security fail **Does not work**

How can I secure Jenkins port 8080 with SSL under apache2 in ubuntu 18.04 Server?

I have been able to successfully install and configure Apache2 server to served on HTTPS. I have been having issues getting Jenkins to use the same SSL certificates and run on Secured port 443. This is my configurations and please, any help will be appreciated. Thank you.

I have the server currently serving a static WordPress site which launches successfully on https port 80 or 443. I also have Jenkins serving successfully on the route of the server but with port 8080.

Is there any way I can get Jenkins to serve right under the Apache2 server like jenkins.server.com/jenkins instead of jenkins.server.com:8080?

    <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

        ServerName jenkins.server.com
        ServerAlias www.jenkins.server.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        <Directory /var/www/html>
            Options +FollowSymlinks
            AllowOverride All
            Require all granted
        </Directory>

        # 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} =jenkins.server.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>

        SSLEngine on
        SSLProxyEngine on

        # SSL certificate and keys. Edit paths to whereever your SSL files are located
        SSLCertificateFile /etc/letsencrypt/live/jenkins.server.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/jenkins.server.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

        ProxyRequests Off
        ProxyPreserveHost On
        RewriteEngine On
        RequestHeader set X-Forwarded-Proto "https"
        AllowEncodedSlashes NoDecode

        ProxyPass / http://jenkins.server.com:8080 nocanon
        ProxyPreserveHost On
        RewriteEngine On
        RequestHeader set X-Forwarded-Proto "https"
        AllowEncodedSlashes NoDecode

        ProxyPass / http://jenkins.server.com:8080 nocanon
        ProxyPassReverse / http://jenkins.server.com:8080

        <Proxy http://jenkins.server.com:8080/*>
                Order deny,allow
                Allow from all
        </Proxy>

</VirtualHost>

How can I secure Jenkins port 8080 with SSL under apache2 in ubuntu 18.04 Server?

I have been able to successfully install and configure Apache2 server to served on HTTPS. I have been having issues getting Jenkins to use the same SSL certificates and run on Secured port 443. This is my configurations and please, any help will be appreciated. Thank you.

I have the server currently serving a static WordPress site which launches successfully on https port 80 or 443. I also have Jenkins serving successfully on the route of the server but with port 8080.

Is there any way I can get Jenkins to serve right under the Apache2 server like jenkins.server.com/jenkins instead of jenkins.server.com:8080?

    <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

        ServerName jenkins.server.com
        ServerAlias www.jenkins.server.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        <Directory /var/www/html>
            Options +FollowSymlinks
            AllowOverride All
            Require all granted
        </Directory>

        # 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} =jenkins.server.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>

        SSLEngine on
        SSLProxyEngine on

        # SSL certificate and keys. Edit paths to whereever your SSL files are located
        SSLCertificateFile /etc/letsencrypt/live/jenkins.server.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/jenkins.server.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

        ProxyRequests Off
        ProxyPreserveHost On
        RewriteEngine On
        RequestHeader set X-Forwarded-Proto "https"
        AllowEncodedSlashes NoDecode

        ProxyPass / http://jenkins.server.com:8080 nocanon
        ProxyPreserveHost On
        RewriteEngine On
        RequestHeader set X-Forwarded-Proto "https"
        AllowEncodedSlashes NoDecode

        ProxyPass / http://jenkins.server.com:8080 nocanon
        ProxyPassReverse / http://jenkins.server.com:8080

        <Proxy http://jenkins.server.com:8080/*>
                Order deny,allow
                Allow from all
        </Proxy>

</VirtualHost>

Htacess : rewrite base url without vhost access

I'm renting a multi-domain server. There is few folders on this server like : - www - site1 - site2

This folders are website, associated like :

  • www -- www.siteA.fr
  • site1 -- www.siteB.fr
  • site2 -- www.siteC.fr

My problem is that in site2 Folder, there is a Symphony 2 website configured : site2/web/app.php must be the first url called when user go on www.siteC.fr but I can't modify VHOST Because it's a multi domain server.

So, I'm trying to write a .htacess file with rules below : - When ./site2 is called with www.siteC.fr, display ./site2/web/app.php, always like www.siteC.fr

How can I do that ?