• Stars
    star
    155
  • Rank 239,979 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Transparent reverse proxy written in PHP

no.php

Transparent reverse proxy written in PHP that allows you to not have to write PHP any more.

This short, single-file, 130-line PHP script is a simple and fully transparent HTTP(S) reverse proxy written in PHP that allows you to never have to use PHP again for a new project, if you feel so inclined, for example if you are forced to host on a fully 3rd-party-managed server where you can't do more than run PHP and upload files via FTP. The PHP script simply reads all requests from a browser pointed to it, forwards them (via PHP's curl library) to a web application listening at another URL (e.g. on a more powerful, more secure, more private, or more capable server in a different data center), and returns the responses transparently and unmodified.

Supports:

  • Regular and XMLHttpRequests (AJAX)
  • All HTTP headers without discrimination
  • GET and POST verbs
  • Content types (HTTP payload) without discrimination
  • Redirects (internal redirects are rewritten to relative URIs)
  • Multipart content type
  • Cookies (with conversion of the backend domain to the no.php host)

Does not support (or not tested):

  • HTTP verbs other than GET and POST (but these are usually emulated anyway)
  • HTTP greater than version 1.1 (e.g. reusable connections)
  • Upgrade to websocket (persistent connections)

Usage illustrated by the standard example

You have a non-PHP web application (called the "backend") listening on https://myapp.backend.com:3000 but due to constraints you must make it available on a shared hosting server called https://example.com/subdir which only supports PHP and can't be configured at all. On latter server, Apache (or Nginx, doesn't matter) will usually do the following:

  1. If a URI points to a .php file, this file will be interpreted
  2. If a URI points to a file that is not existing, a 404 status will be returned.

Using no.php, to accomodate the second case, all URIs of the proxied web app (including static files) must be appended to the URI https://example.com/subdir/no.php. For example:

https://example.com/subdir/no.php/images/image.png
https://example.com/subdir/no.php/people/15/edit

If your backend app supports that extra /subdir/no.php prefix to all paths, you are all set and ready to use no.php. Then:

  1. Simply copy no.php into the subdir directory of example.com
  2. Change $backend_url in no.php to "https://myapp.backend.com:3000"
  3. Point a browser to https://example.com/subdir/no.php

In Ruby on Rails for example you must do a minimal adaptation to facilitate the mentioned URL prefix -- please consult the Ruby on Rails documentation for full details, but here is a hint:

ENV['RAILS_RELATIVE_URL_ROOT'] = "/subdir/no.php"

Rails.application.configure do
  config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
end

Rails.application.routes.draw do
  scope path: ENV['RAILS_RELATIVE_URL_ROOT'] do
    # routes here
  end
end

More Repositories

1

janus-rtpforward-plugin

Plugin for Janus forwarding RTP and RTCP packets to an external UDP receiver/decoder, e.g. a GStreamer pipeline
C
83
star
2

escper

Ruby gem for printing of images and text on one or many thermal printers
Ruby
66
star
3

SalorHospitality

The innovative Point of Sale Solution serving the Hospitality Industry
Ruby
52
star
4

grbl-streamer

Universal interface module written in Python 3 for the grbl CNC firmware
Python
46
star
5

grbl-gui

Gcode scripting, 3D visualization and streaming for the grbl CNC controller
Python
34
star
6

docx_converter

Ruby gem converting Word docx files into html or LaTeX via the Kramdown syntax
Ruby
34
star
7

minnie-janus

Small, ES8, isomorphic library for interfacing with the Janus WebRTC gateway.
JavaScript
31
star
8

gcode-machine

A simple CNC state machine implemented in Python that can be used for simulation and processing of G-code
Python
19
star
9

pyglpainter

Python OpenGL Painter - Minimalistic but modern OpenGL drawing for technical applications
Python
17
star
10

clang-wasm-browser-starterpack

Minimal working examples of C and C++ software development targeting the web via WebAssembly.
Nix
17
star
11

noweffects

Proof-of-concept of HTML5 + JavaScript + CSS3 RGBA video overlays on top of live GStreamer video pipelines.
C++
13
star
12

woocommerce-shipping-external-fetch

Shipping Plugin for WooCommerce fetching the shipping rates as JSON from an external microservice
PHP
12
star
13

sanitize-dom

Isomorphic library for recursive manipulation of live WHATWG DOMs.
JavaScript
5
star
14

vagrant_janus-rtpforward-plugin_demo

A provisioned virtual machine demonstrating janus-rtpforward-plugin
Shell
4
star
15

socket.io-bridge

Isomorphic library for real-time, bidirectional, event-based communication between two Socket.IO clients
JavaScript
2
star
16

md2sv

Extensible Markdown to Svelte Transpiler
JavaScript
2
star
17

image_debian-gpgpu

Dockerfile for a Debian base image with AMD and Nvidia GPGPU support
Dockerfile
1
star
18

TTYtter_extensions

Extensions to the TTYtter Twitter client
Perl
1
star
19

bmp180

Golang package for interfacing with BMP180 environmental sensor
Go
1
star
20

image_boinc-client

Dockerfile for BOINC client with Virtualbox, AMD and Nvidia GPGPU support
Dockerfile
1
star
21

webDSKY

Emulation of the DSKY user interface of the Apollo Guidance Computer for the Web platform
JavaScript
1
star
22

captain-hook

Tiny configurable and isomorphic event emitter library for mixing into JavaScript objects
JavaScript
1
star
23

gltf-starfield

Translate the Yale Bright Star Catalog to a glTF 3D model
TypeScript
1
star
24

webAGC

A port of yaAGC, an emulator of the Apollo Guidance Computer, to the web platform
JavaScript
1
star
25

barograph

Infrasound detector with spectral analysis
Makefile
1
star