Giter Club home page Giter Club logo

seo-proxy's Introduction

seo-proxy

If you serve your website using https and you have setup your nginx or Apache to redirect all http-requests to the https equivalent, then you might get bad ratings from Google and other search engines if you don't handle bad requests properly. This means the search engines don't like it if you answer on a request with a 301/302 redirect response and when they then request the URL from the Location header, they receive a 404.

Since the webserver itself can hardly determine whether a particular URI is valid or not if the respone is created from a dynamic backend, you cannot solve this problem in the Apache/nginx config directly.

That's where this seo-proxy comes in handy: it will take incoming requests and forward them to the configured target. If the target responses with a 200 status, then the proxy will redirect the client to that target URL. If it's a 404 response, the proxy will serve that response directly.

To speed things up, this proxy caches all previously requested URLs and the according response. For now it just keeps them in memory, but adapters to caching backends like Redis or memcache are planned.

Usage

  1. Download the zip file or clone this repository

    git clone https://github.com/CodeLoversAt/seo-proxy.git
    cd seo-proxy
  2. Install dependencies

    npm install
  3. Create a new config.json from the template config.dist.json and update the file to match your setup.

    cp config.dist.json config.json
  4. Start the proxy

    node index.js
    > Proxy started on http://127.0.0.1:8888
  5. Setup your webserver to forward all http requests to your proxy instance. Here's a sample nginx server configuration:

    upstream proxy {
        server 127.0.0.1:8888;
    }
    
    server {
            listen 80;
            
            server_name example.com www.example.com;
    
            location / {
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_pass http://proxy;
            }
    }

Run as a service

You might want to run that proxy as a service on startup. We suggest using node-startup or forever for that purpose.

License

MIT

seo-proxy's People

Contributors

dvelopment avatar

Watchers

 avatar James Cloos avatar CodeLovers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.