url rewriting – 404 Rest Route not found – when serving behind “proxy”

To avoid CORS and speed up my static site, I have made a “proxy” from my static site.

Basically, I can make a request to: staticsite.com/wp-json/some-endpoint and it fetch and return the response from mywordpresssite.com/wp-json/some-endpoint (pretty cool if you ask me). It works fine for almost all my endpoints, however, I have just discovered that it doesn’t work with this package: https://github.com/CalderaWP/searchwp-api-route

When I go to: staticsite.com/wp-json/swp_api/search?s=query it correctly returns the data from mywordpresssite.com/wp-json/swp_api/search?s=query,however it returns "No route was found matching the URL and request method".

I am not sure what I am doing wrong, or what I could do to avoid this issue. It seems specific to this plugin somehow, since all the other endpoints work fine.

If I visit the endpoint directly from mywordpressiste.com it works fine.

linux – NGINX reverse proxy on root path returns 401 and 404 errors

I’m using NGINX to load balance a docker swarm cluster on Digital Ocean. I have swarmpit installed and I want to reverse proxy to it with an ssl certificate and using a custom port so that I can privately access it and restrict traffic.

I’m not using any custom paths or anything fancy. I’m literally just reverse proxying from the root path under a subdomain to the container.

The page does load but it seems like anything not in the root doesn’t load and either comes up with a 404 or a 401 error. As a result the page appears broken with only the root-level content loading.

Server Config

server {
    listen #### ssl;

    ssl_certificate /etc/letsencrypt/live/###.#####.###/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/###.#####.###/privkey.pem;

    include snippets/ssl-params.conf;
    include snippets/optimize-assets.conf;

    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'Upgrade';
        proxy_cache_bypass $http_upgrade;
        proxy_pass http://swarmpit;
    }
}

Upstream Block

upstream swarmpit {
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
}

I also have many defaults set in the nginx.conf file such as

nginx.conf

...
    proxy_redirect          off;
    proxy_set_header        Host            $host;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_pass_request_headers on;
...

What I’m seeing though is

Several 404 and 401 errors

An example of one of the 404 responses

Request URL: https://###.#####.###:####/css/rc-slider.css
Request Method: GET
Status Code: 404 Not Found
Remote Address: ###.###.###.###:####
Referrer Policy: no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 555
Content-Type: text/html
Date: Sat, 30 May 2020 05:50:54 GMT
Server: nginx/1.18.0
Accept: text/css,*/*;q=0.1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: _ga=#####
DNT: 1
Host: ###.#####.###:####
Referer: https://###.#####.###:####/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.125

I’m not sure why this isn’t working but I’ve run out of help after a lot of Googling and I’m sure it’s something that’s probably simple. Any help is appreciated.

404 – Which server status code is appropriate for ugly bots scanning server for vulnerabilities

I think 404 does make sense in some ways. If an undesirable walks up to your house, sure you could shout at them to leave, but it might make more sense just to not answer the door. This has the added bonus of them not knowing whether you’re actually not home or just not answering. A 404 is the equivalent of not answering the door.

Plus it’s semantically correct, in the sense that those paths don’t actually exist on your server anyways.

As a related thought, I would consider adding those paths to your robots.txt, so that you can be certain you’re only banning bots that are hitting those URLs maliciously, and not for example because bingbot found a link to them on some dark corner of the internet.

403 implies that the resource exists but the request will not be fulfilled, and 410 implies that the resource used to exist but does no longer. Neither of those are really true, so I think 404 is the most correct anyways.

applications – How do I enable a forced stop & disabled Bluetooth Share app on Android 4.0.4 (Ice Cream Sandwich)

Over enthusiastic to disable many distracting apps on my Sony Xperia U (ST25i) I went “settings>apps>all” and disabled away. Where no disable option was available, I clicked on force stop. With Bluetooth Share I stupidly took it to be a social networking app and disabled it, later force stopping it. Dumb, I know, but how do I get it back? I’m fairly new to all of this, obviously, so please be very specific in responding. Many thanks.

terraform – Error loading zone ‘europe-west1-a’: googleapi: Error 404: The resource ‘projects/google-project-id/zones/europe-west1-a’ was not found, notFound

Having this error and it is driving me crazy…. I can’t get it to create more than 1 VM with a static IP.

Here is my main.tf

provider "google" {
  credentials = file("terraform-key.json")
  project = var.project
  region  = var.region
  zone    = var.zone
}

terraform {
  backend "gcs" {
    bucket = "my-bucket"
    prefix = "terraform"
    credentials = "terraform-key.json"
   }
}

resource "google_compute_network" "vpc_network" {
  name = "new-terraform-network"
}

resource "google_container_cluster" "primary" {
  name     = "prod-cluster"
  location = var.zone
  remove_default_node_pool = true
  initial_node_count       = 1

  master_auth {
    username = ""
    password = ""

    client_certificate_config {
      issue_client_certificate = false
    }
  }
}

resource "google_container_node_pool" "primary_preemptible_nodes" {
  name       = "pool-1"
  location   = var.zone
  cluster    = google_container_cluster.primary.name
  node_count = 3

  node_config {
    preemptible  = true
    machine_type = "n1-standard-1"
    disk_size_gb = 10
    disk_type = "pd-standard"


    metadata = {
      disable-legacy-endpoints = "true"
    }

    oauth_scopes = (
      "https://www.googleapis.com/auth/logging.write",
      "https://www.googleapis.com/auth/monitoring",
    )
  }
}
resource "google_compute_address" "vm-host"{
  count =  var.vm-host-number
  region  =  var.vm-host-region
  name  = "vm-host-${count.index}"
}


resource "google_compute_instance" "vm-host" {
  name         = "vm-host-${count.index}"
  machine_type = "f1-micro"
  zone         = "europe-west1-a"
  count        =  var.vm-host-number

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }

  network_interface {
    network = google_compute_network.vpc_network.name
    access_config {
        nat_ip = "google_compute_address.vm-host-${count.index}.address"
    }
  }
}

My variable file

variable "project" {
  default = "my-project"
}

variable "region" {
  default = "us-central1"
}

variable "zone"  {
  default = "us-central1-c"
}

variable "cidr_ip" {
  default = "10.0.0.0/16"
}

variable "vm-host-number"{
  default = "2"
}

variable "vm-host-region"{
   default = "us-central1"
}
variable  "vm-host-zone"{
   default = "europe-west1-a"
}

The error –

Error: Error loading zone 'europe-west1-a': googleapi: Error 404: The resource 'projects/GoogleProjectID/zones/europe-west1-a' was not found, notFound

  on main.tf line 65, in resource "google_compute_instance" "vm-host":
  65: resource "google_compute_instance" "vm-host" {

Cant understand why it won’t create the VMs, If i try the same to just create 1 VM, without the variables/count it works fine ><. I mean the zone definitely exists…

java – Return a 404 when a resource is not found in Spring Boot

I wrote this code in order to return a http status of not found to my users in case the resource is not present in the DB.

@RestController
public class ExampleController {

    public final ExampleService exampleService;

    @Autowired
    public ExampleController(ExampleService exampleService) {
        this.exampleService = exampleService;
    }

    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    public class ResourceNotFoundException extends RuntimeException {
    }

    @GetMapping("/api/mappings/get-by-id/{id}")
    public ExampleDto getExampleById(@PathVariable String id) {
        Example example = exampleService.findById(id).orElse(null   );
        if (example == null) throw new ResourceNotFoundException();
        return new ExampleDto(example);
    }

}

I would like to know if this code can be considered good and robust enough or if it can be improved and how.

magento2 – Magento 2 Advanced Reports 404 page

First of all create manually a new Reports user, open :

System->Extensions->Integrations

Check is a user with the name “Magento Analytics user” is there. If not please do the next steps:

  • press New Integration button
  • paste the name – “New Integration”, into the name input.
  • in the field “Your Password” type the current admin password
  • at the left tab, press the “API” tab.
  • In the “Resource Access” dropdown, select the “All” option, and in the next step press
    “continue” (do not change any keys, tokens,etc.) Press save.
    Clean/flush caches.

Now you can check your current integration status in the :

Stores->Configurations->General->Advanced reports.

If the Status is enabled -> everything is fine (check it in 5-10 mins). If it is pending, go to prev. step and press in the grid “reauthorize” and check again your current status. enter image description here

And now you should wait for 24 hrs for a report generation. But here we have a small lifehack, just follow these steps:

Go to the Magento root dir via ssh or terminal: Download the latest stable N98-Magerun phar-file from the file-server:

wget https://files.magerun.net/n98-magerun2.phar

add “run” permissions:

chmod +x ./n98-magerun2.phar

and after that just simply run:

./n98-magerun2.phar sys:cron:run analytics_collect_data

After these last steps, please wait ~10-15 mins and press “Go to advanced reports” button at the right top corner in the Magento dashboard.

If it was helpful, please vote up! With love from Ukraine <3

java – Erro status 404 (Servlet)

Estou tendo um problema com essa servlet, quando inicio com o tomcat aparece o erro 404 e aprensenta a seguinte mensagem “The requested resource (/teste/NovaEmpresa) is not available”.

JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <form method="post" action="NovaEmpresa">
        <label>Nome da empresa:</label>
        <input type="text" name="nome"/>
        <button type="submit">Enviar</button>
    </form>
</body>
</html>

Servlet

package teste;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/NovaEmpresa")
public class NovaEmpresa extends HttpServlet{
    protected void service(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("teste!!!!");
    }
}

magento 1.9 – initiation oAuth1 – 404

I am trying to get an access token for a third party app, following the documentation here.
However, I always end up with a 404 error. I tried different clients (python and postman), with different signature methods (HMAC and PLAINTEXT) I also tried to put the oauth_callback as a request parameter (against the official document, but I saw it in another tutorial) but it didn't help either. Attached is a screenshot showing the Python script used and the output showing the correct construction Authorization header (not sure if I should put the /index.php at BASE_URL so I tried both) Also, (obviously) anonymized the key and secret after execution.

enter the image description here

I have been struggling with this for a few days, any help will be greatly appreciated.

Thank you.

Sitemap on WordPress Yoast SEO with nginx web server giving 404 error

I installed yoast seo on a wordpress website that is on the nginx web server, but when i clicked the xml sitemap link it shows 404 not found error. Any suggestions to solve this?