linux – Serve Server Root instead of Subfolder when accessing my webserver through it’s domain

I have a apache 2.4.38 webserver, running on my Debian 10 Buster server. In my /var/www/html, I have a index.html file, and a folder “nextcloud”, with a nextcloud instance installed. If I type the IP of my server into my browser, the index.html file shows(that’s the behavior I want). However, if I type my domain name into my browser, only the domain, without adding /nextcloud to the URL, nextcloud loads. This is unwanted behavior. When simply typing in my domain name, without specifying a subfolder, I want my custom index.html to show. In /etc/apache2/sites-enabled, I have 3 files:

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

nextcloud.conf

<VirtualHost *:80>
     ServerAdmin MY_EMAIL_CENSORED
     DocumentRoot /var/www/html/nextcloud/
     ServerName MY_DOMAIN_CENSORED

     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =MY_DOMAIN_CENSORED
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} (END,NE,R=permanent)
</VirtualHost>

nextcloud-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
     ServerAdmin MY_EMAIL_CENSORED
     DocumentRoot /var/www/html/nextcloud/
     ServerName MY_DOMAIN_CENSORED

     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


SSLCertificateFile /etc/letsencrypt/live/MY_DOMAIN_CENSORED/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/MY_DOMAIN_CENSORED/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Thank You very much for your time, attention and help!

Simon

perl – Serve and Authenticate via JWT tokens via Mojo::JWT

Hello fellow Perl hackers,

I have been faffing about with Mojo::JWT the last day or two and feel I have come up with something that should securely serve a JWT token to authenticate a user.

As my moniker suggests, this is all pretty new to me. Therefore I look for feedback on the security of this implementation (apart from the obvious hardcoded username/password pair) and ways that I could trim the lines of code.

I have discovered under in Mojolicious to restrict routes, however as I am using OpenAPI, is there an equivalent to this.

Further, which would be good candidates to use for helpers? And while on the subject of helpers. What would be the difference in just using other sub-routines, sans the helper keyword.

I generated Mojo app via mojo generate app appname and follows is the Controller that I have created for the OpenAPI endpoints.
I have been using curl to test these endpoints and these work as expected.

package mojojwtauth::Controller::Example;
use Mojo::Base 'Mojolicious::Controller', -signatures;
use Mojo::JSON qw(decode_json encode_json);
use Mojo::JWT;

sub restricted {
  # Validate input request or return an error document
  my $self = shift->openapi->valid_input or return;
  
  # get token from authorization header
  my $jwt = $self->req->headers->authorization =~ s/^s*S+s*//r;
  # decode token
  eval { my $claims = Mojo::JWT->new(secret => 's3cr3t')->decode($jwt)};
  if ($@) {
    $self->render(openapi => (
      json => {error => 'Access Denied: Restricted Area'},
      status => 401
      )
    );
  } else {
    $self->render(openapi => (
      json => {success => 'Access Granted'},
      status => 200
      )
    );
  }  
}

sub get_token {
  # Validate input request or return an error document
  my $self = shift->openapi->valid_input or return;
  
  # check if username and passord is equal to hardcoded variables
  my $data = $self->req->json;
  if($data->{username} eq "philip" && $data->{password} eq "secret" ) {
      
    #  create token
    my $exp = time() + 86400;
    my $payload = {id => 1, 
                   exp => $exp,
                   iss => 'Mojolicious API'};
    my $jwt = Mojo::JWT->new(claims => $payload, secret => 's3cr3t')->encode;
    
    # Return useful info from database query when doing real password check
    my $user = {id => 1,
                name => $data->{username},
                username => $data->{username}};

    # Return token and user data
    $self->render(openapi => (
      json => { token => $jwt,
                user => $user },
      status => 200
      )
    );
  } else {
    # else return error
    $self->render(openapi => (
      json => {error => 'Invalid Username or Password'},
      status => 200
      )
    );
  }
}

1;

I am really new to this so please any feedback is greatly appreciated.

postgresql – How to serve Images with Heroku and Django

After deoploying to heroku it was initially working fine, but would disappear (I’m assuming because of the unmounting thing)

So some googling and I changed DEBUG = False and also added ALLOWED_HOSTS = ('localhost', '127.0.0.1', 'HEROKU LINK') but that didn’t fix the problems and now my images are not even being shown after upload

I’ve looked at a few solutions but nothing that really explains (or particularly works), it shows my image location as HEROKU-LINK/media/photos/2021/07/16/dev.jpeg

Using Heroku for Django Media Files

My static files are fine, they don’t disappear only my images.

I have the heroku postgres addon as a database, do I need to add something like CLoudinary or AWS S3?

Or is there a way to get it working normally with Heroku (and not adding more cost to my side project blog)

my settings.py

STATIC_URL = '/static/'
STATICFILES_DIR = (
    os.path.join(BASE_DIR, 'build/static')
)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

my model

class BlogPost(models.Model):
  title = models.CharField(max_length=100, default='Title')
  slug = models.SlugField()
  category = models.CharField(max_length=55, choices=Categories.choices, default=Categories.RANDOM)
  thumbnail = models.ImageField(upload_to='photos/%Y/%m/%d/')
  excerpt = models.CharField(max_length=150)
  month = models.CharField(max_length=9)
  day = models.CharField(max_length=2)
  year =models.CharField(max_length=4, default='2021')
  content = models.TextField()
  featured = models.BooleanField(default=False)
  hide = models.BooleanField(default=False)
  date_created = models.DateTimeField(default=datetime.now, blank=True)

lo.logic – Can this graph theory serve as a foundational theory of mathematics?

Working in mono-sorted first order logic, add primitives of equality and its axioms, set membership $in$, a partial ternary relation $to$ denoting is the direction from to, and at last a total unary function $cal S$ dentoing the “structure” of.

Axioms for sets:

Extensionality: $forall x forall y (forall z (z in x iff z in y) implies x=y)$

Membership: $x in y implies forall z in x (z =x)$

Atomicity: $forall x exists y: y in x$

Comprehension: $(exists y (y={y} land phi)) implies exists x forall y (y in x iff y={y} land phi)$; for every formula $phi$ in which $x$ is not free.

Axioms about direction:

Naturality: $to(x,a,b) implies x,a,b text{ are singletons }$

Uniqueness: $to (x,a,b) land to(y,c,d) implies (x=y iff (a=c land b=d))$

Incompatibility axioms:

Define:
$node(a) iff exists x exists b :, to (x,a,b) lor to (x,b,a)$

Define: $arrow(x) iff exists a exists b :, to(x,a,b)$

Dichotomy: $node(a) implies neg arrow(a)$

Duality: $ a={a} implies node(a) lor arrow(a)$

Axioms about size:

Definitions:

A graph is a set closed under node-hood. That is, all nodes connected by arrow elements of it are elements of it.

A scatter is a set of nodes only.

The scatter of a graph is the set of all of its nodes.

“Nodes” is the set of all nodes.

A graph is to be called small if and only if its scatter is strictly subnumerous to Nodes.

Where “strictly subnumerous” is defined in the cusmtomary manner after existence of injections in only one direction.

Two graphs are said to be separate if there is no arrow connecting a node from one of them to a node in the other.

A graph is continuous if and only if it’s not the set union of two separate graphs.

A moiety of a graph is a maximal continuous subgraph of that graph. That is, no continuous subgraph of that graph exists that has it as a proper subgraph of.

Axioms:

Infinity: There is a small infinite graph.

Power: for every small graph there exists a small power graph.

The power graph of $G$ is one whose moieties are isomorphic to subgraphs of $G$, having no two distinct moieties being isomorphic to each other, and where every subgraph of $G$ is isomorphic to some moiety of it.

Inaccessibility: The small fusion of small separate graphs is small.

In other words if a graph have less many moieties than the nodes in Nodes, and each moiety is small, then that graph is small too.

Axioms about structure:

Abstraction: $forall graphs x,y: x approx y implies cal S(x) = cal S(y) $

Canonicity: $forall graph x: cal S(x) approx x$

Define: $x approx y iff exists f:f text{ is isomorphism from } x text{ to } y$

Where:

$f text{ is isomorphism from } x text{ to } y iff \ f text{ is a bijection from } scatter (x) text { to } scatter (y) land \forall a,b in x ((exists k in x :to(k,a,b)) iff exists l in y :to (l,f(a),f(b))) $

Separateness: $G, H text{ are small moieties } implies mathcal S(G) disjoint mathcal S(H) $

Axioms about choice:

Choice: for every graph $G$, there exists a scatter graph that contains exactly one node from each moiety of $G$.

The above structure theory does interpret ZFC and actually MK. The category of all sets of ZFC is definable as the set of all structures of small extensional mono-rooted trees with finitely long branches, plus all arrows between those structures including the identity arrows over their nodes. By extensional tree, it’s meant that no node of it can have two distinct isomorphic maximal subtrees stemming from it. The set membership relation of ZFC can be defined over those structures as structures of maximal subtrees whose root nodes are those connected to the root node of the main tree directly through arrows. So it does provide an explication about sets and their membership in the standard sense of ZFC. I believe also that the category of all small categories can as well be defined here in almost straightforward manner. So, this theory can serve as a natural foundation of both Set and Category theory.

Can we regard such a theory as a Candidate for a foundational theory of mathematics?


Technical development about size expressions:

The $phi$-cardinality of $x$ is the number of $phi$ parts of $x$, this occurs when any two parts of $x$ satisfying $phi$ are separate (disjoint). Now this is determined by existence of a one-to-one relation $R$ from $phi$ parts of $x$ to nodes of a scatter $k$, that is, all arrows in $R$ that are sent from nodes of $x$ to an element $j$ of $k$ all of them come from nodes in a single $phi$ part of $x$, and of course for every node of $k$ there is an arrow in $R$ that comes from a node of $x$ to it, and to assure the one-to-one genre we must have distinct nodes in $k$ having nodes beloning to distinct $phi$ parts in $x$ with arrows coming from those to them. Now the $phi$-cardinality of $x$, symbolized by $|x|^phi$ would be equal in this case to $|k|$.

More generally, if we have a binary relation $Q$ and an object $x$, then $|x|^Q$ is the cardinality of all objects that bear the relation $Q$ to $x$ provided that all those objects are separate! This would have the same above definition, we only replace the relation $part$ by $Q$.

Now we’ll define cardinality generally as the structure of a scatter graph, and so it reflects how many nodes are there in scatter graphs. So formally

Define:$ |x|= y iff scatter(x) land y=mathcal S(x)$

So the node-cardinality of any graph is defined as:

$|x|^{node} = y iff exists k exists R: scatter(k) land R: scatter(x) to k land R text{ is a bijection } land |k|=y$

This will boil down to:

$|x|^{node} = |scatter(x)|$

Now

$|x|^{moiety} = y iff exists k , exists R: scatter(k) land R text{ is one-to-one from moieties of } x text{ to nodes of } k land y=|k|$

So, the last two size axioms cab be formally written as:

Power:$|x|^{nodes} < |Nodes| implies |x|^{substructure} < |Nodes|$

Inaccessibility: $|x|^{moiety} < |Nodes| land forall y : y text{ moiety of } x to |y|^{nodes} < |Nodes| \implies |x|^{nodes} < |Nodes|$

angular – Rodar Ng Serve no Windows server automatico

angular – Rodar Ng Serve no Windows server automatico – Stack Overflow em Português

architecture – How to set up 2 versions of Single Page Application and serve the right version to users based on the backend setting?

We develop a Single Page Application (SPA) for enterprise clients. When we deploy a new version of our SPA we would like to upgrade a subset of clients whilst leaving the other clients on the more stable previous version. After the new version become stable we then upgrade the rest of clients. The release cycle will always go on like this but each time we may choose a different subset of clients to try the new version.

I have thought this is a pretty standard release practice for enterprise application, call it beta-release or whatever. But to my surprise I can’t much useful information about how to do it for SPA. I also face some technical difficulty, e.g. when a user sends the first GET request of the SPA (say, typing the url of the SPA in the browsers) how do I send him the correct version? It involves DB query to find out the correct version for him, but how to do that in the http request/response cycle ?

I search softwareengineering, find this Why make the login page to a single page application a separate page? It is actually what I am thinking now, e.g. make the login part a standalone app apart from the rest of my SPA. So in the login process I can decide which version I should show to this user and redirect him that version.

But is there other way to achieve what I need ? I think it involves an overall design/overhaul to my current SPA architecture.

— Update —

I only allow a client to use one version I assign to him. A client can’t use both versions. So if I design to add v1/v2 in the URL and he types the wrong version for him I will redirect him to the correct version. But I have not decided whether to add version number to URL path. This is another design choice to make.

Is there a war against legal VPN services that serve privacy? Why?

I use OpenWrt and by default all outgoing traffic is tunneled through Wireguard VPN endpoint (provider from the list of privacytools.io recommendations).

Often I get an “Access Denied” or the page does not load (timeout). Famous local sites, which block legal VPNs (example Zalando). As a workaround I use the integrated Opera VPN, which has never been locked out.

Why do site operators block legal VPNs? Often sites that block VPNs are overloaded with ads. Are they so greedy for the location info associated with the provider IP?

Ezmob – Self -Serve | POP, Push, Native, Display ad-network | Proxies-free

unnamed-png.19062

Hot Crypto Traffic – WW Geos !

Crypto is one of the Hottest verticals, and yet the hardest to optimize! Crypto offers often have some of the highest payouts in the industry. The average is normally a couple of hundred dollars.

That said, we’re giving away you the best strategy to make it big with crypto ads!

How to Create a Successful Campaign:
-> Add at least 4 creatives in order to make a proper A/B test
-> Make sure to make a separation between desktop and mobile campaign
-> Don’t limit yourself too much — running your campaigns in more than one GEO’s is much recommended!
-> Pre lander can get you higher CR% so make sure to have them
-> Make sure to integrate our postback – It will help us to help you.
-> Gather as much information and data as possible in order to optimize
-> Proper testing budget is the equivalent of 2 to 3 payouts

GET 10% ON YOUR FIRST DEPOSIT – USE CODE – PROMO10JU

Setup an account – HERE

Available Payment Methods:
Paxum / Payoneer / Webmomey / PayPal / CC / Btc / Wire

Our support team is second to none – Get in touch!

Thanks,
EZmob

 

nginx serve static files AND reverse proxy

I want the browser to be in constant communication (websocket) with my backend servers as they are constantly receiving data. But I also want static files to be served to them by nginx. In other words, I want nginx to serve static files AND ALSO proxy to my backend servers. I’ve tried putting both directives in the same location block:

location / {

        # SERVE STATIC FILES:
        root C:blah/blah/blah;
        index mysite.html;

        # ANDDDD REVERSE PROXY TO BACKEND SERVERS:
        proxy_pass https://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
}

.. but this just skips the serving of static files and goes straight to my backend servers.

I’ve also tried:

location / {

# SERVE STATIC FILES:
root C:blah/blah/blah;
index mysite.html;
try_files $uri $uri/ @proxy;

}

location @proxy {

# ANDDDD REVERSE PROXY TO BACKEND SERVERS:
proxy_pass https://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;

}

.. but of course this just serves the static files and does not proceed with the proxy since the mysite.html was found.

I’ve also tried:

location / {

# SERVE STATIC FILES:
root C:blah/blah/blah;
index mysite.html;

}

location / {

# ANDDDD REVERSE PROXY TO BACKEND SERVERS:
proxy_pass https://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;

}

.. but this produces an error as there are now two location / blocks.

Does anyone know how to make nginx serve static files AND proxy to a backend server?

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies