HomeJavaModsSpigot HTTP Server (BETA)
Spigot HTTP Server (BETA)
SpigotHttpServer-sm.png

Spigot HTTP Server

A basic HTTP Server implementation with PHP gateway support, and global variables based on your spigot instance.

Why did you make this?

A friend of mine has gotten a host which doesn't have Apache/Nginx available to the users, but did have PHPMyAdmin, and PHP available to the user. With that in mind, I developed this plugin so he can run his small server information page with PHP support for fun statistics.

Downloading this Plugin?
Think about writing a short review!
It's much appreciated.

Got bugs in the code?
Rather than leaving a review with bug reports...
Click on the Discussion tab, or send me a Personal Message.
Thank you.​

Features
** Needs testing. Possible bugs.

Commands
Spigot HTTP Server now comes with commands to control the server. They are simple, and can be executed by someone with the appropriate permissions.

httpd (start|stop|restart|reload)


Permissions
Currently there is only one permission node for an admin.
Installation

TestIndex.jpg
Installation is fairly simple:

Requirements:
Install Directions:
  1. Create a new folder in your plugins directory called SpigotHttpServer
  2. Copy and save the example config below to your SpigotHttpServer folder, and edit the settings.
    • server-ip - This is the IP your HTTP server will bind to.
    • server-port - This is the Port (which must not be already bound) your HTTP Server will bind too.
    • server-path - This is the absolute path to your public_html folder. It doesn't need to be in your SpigotHttpServer plugin folder, but it must exist and have the correct permissions for web. If you need help finding your paths you can run this plugin and search your server logs for [SHSPaths] - SHSPaths.jar (You must run this with Spigot HTTP Server installed in plugins folder)
  3. (Optional) If PHP is installed on your system, you can set php-gateway-enabled to true. Than, you will need to edit the php-path to point to your PHP bin. On most Linux systems it can be left as "php".
  4. Drop the SpigotHttpServer*.jar into your plugins folder.
  5. Start your Server
  6. Visit your website at the desire IP and Port!

Config Example

This is the example config you should use before first starting your server.

Note (Windows): On windows your php-path should point to your php.exe. (You can download PHP form here: http://windows.php.net/download/ or use another instance like WAMPs)


Note (Linux): On linux if you do not know your PHP path you may have to guess if you do not have access to the terminal. If you do, try running: find / -name "php"
Code (YAML):
# Web Server Setup

# Web Site/Network Name
server-name
: Spigot HTTP Server

# Web Site/Network Address
server-address
: null

# Server IP (Eg localhost / 127.0.0.1 / Bound External IP )
server-ip
: 127.0.0.1

# Additional IPs, do not uncomment unless assigning available ips on your network
#additional-ips:
# - 192.168.0.1

# Web Port (Default: 8080)
server-port
: 8080

# Server Root Path
# This is where your HTTP server root is. No trailing slash! Examples:
# Windows: C:\Users\Minecraft\Spigot\plugins\SpigotHttpServer\public_html
# Linux: /home/spigot/server/plugins/SpigotHttpServer/public_html
server-path
: /home/spigot/server/plugins/SpigotHttpServer/public_html

# Max simultaneous connections
# Considering you are running a small server via a plugin on your
# Spigot Server, considering keeping this low. Connections over this limit
# will be rejected with a 503 Service Unavailable Error.
# Setting this to 0 or 1 will drop all incoming connections serving the 503
max-connections
: 200

# Kill Switch
# If this enabled, instead of serving a 503 error when connection limit is
# reached, Spigot HTTP Server will shutdown for X time before returning online
kill-switch-enabled
: false

# Kill Switch - Restart Timer (In Ticks)
# [Default: 2400] - 2 Minutes
kill-switch-restart
: 2400

# PHP Gateway Enabled
# This shouldn't be enabled if you do not have PHP installed
php-gateway-enabled
: false

# PHP Path
# This is the full path, or command to your PHP parser
# Example: /user/bin/php
php-path
: php

# SHS Tags Enabled
# SHS Tags incorperates a secondary parser before pages are served and replaces
# Registered types with their corresponding value. You can accesss SHSTags through
# Spigot HTTP Server plugin and add your own custom types.
shstags-enabled
: true

# SHS Online Userlist Avatar Size
# [Default: 24]
shstags-avatar-size
: 24

# Max HTML Online Player List Count
shstags-max-online-list-shown
: 25

# Did we, or do we want to generate the default index
# This is set false for first run to generate an example
generated-index
: false

SHS HTML Tags
Spigot HTTP Server now comes with a built-in parser for special tags which can output information from your server without the need for PHP and the use of the $_SHS array.

List of Stock SHS Types:


Example Tag Usage:

Code (HTML5):
<div id="usersonline">
    We have <shs type="players_online_count"> of <shs type="max_players"> players online. <br />
    <p id="userlist"><shs type="players_online_list"><p>
</div>

Adding SHS Tags
Spigot HTTP Server now allows you to hook into it's public SHSTags class and add your own SHSTags which can be used for tons of unique features via a simple HTML page.

First add SpigotHttpServer*.jar to your Build Path

Example Plugin:
Code (Java):

import org.bukkit.plugin.java.JavaPlugin ;

// Import SHS Tags
import wa.was.webserver.lib.SHSTags ;

public class SHSTagTest extends JavaPlugin {

  @Override
  public void onEnable ( ) {

      // Add a test value to Spigot HTTP Server's SHSTags
      try {
       SHSTags. addReplacement ( "test_key", "<p style=\"font-seigh:bold;\">Hello World!</p>" ) ;
      } catch ( Exception e ) {
       e. printStackTrace ( ) ;
      }

      // Update the test value
      try {
       SHSTags. addReplacement ( "test_key", "<p style=\"font-seigh:bold;\">Hello Mars!</p>" ) ;
      } catch ( Exception e ) {
       e. printStackTrace ( ) ;
      }

      // Remove a value
      try {
        if ( SHSTags. containsType ( "test_key" ) ) {
         SHSTags. removeReplacement ( "test_key" ) ;
        }
      } catch ( Exception e ) {
       e. printStackTrace ( ) ;
      }

      // Has value
      try {
        if ( SHSTags. containsValue ( "<p style=\"font-seigh:bold;\">Hello Mars!</p>" ) ) {
          System. out. print ( "I found the value" ) ;
        }
      } catch ( Exception e ) {
       e. printStackTrace ( ) ;
      }

  }

}
 




Example PHP "Script"

Spigot HTTP Server only handles PHP through a gateway which uses the PHP parser installed on your system seperately. You must define the path to your PHP bin for this to work. It is not advised to use PHP-CGI. Currently PHP Scripts are limited to the "text/html" content type. You cannot use $_POST, $_GET, $_COOKIE, etc, but I have simulated $_GET with arguments. So you may use $_GET as you normally would in a basic manner.
Code (PHP):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PHP Test</title>
  <style type="text/css">
   .center {
     width: 400px;
     text-align: center;
     margin: 150px auto;
     font-size: 50px;
   }

   .center.reset {
     font-size: 14px;
     text-align: left;
   }
  </style>
</head>
<body>
   <div class="center">
     Hello
      <?php

        /*
       # Spigot HTTP Servers's PHP Gateway
       # is only using the PHP Parser.
       # Because of this, we DO NOT have:
       #
       # $_POST
       # $_GET
       # $_COOKIE
       #
       # Available to us. But we can still
       # simulate $_GET...
       #
       # Spigot HTTP Server takes your URI
       # and parses the query string to
       # arguments, and then pre-processes
       # your PHP file to utilize those
       # arguments as a basic $_GET array
       #
       # */


        // Let's print the of the argument world!
        // Notice we can use $_GET as per-normal.
        echo $_GET [ 'world' ] ;

      ?>
   </div>
   <div class="center reset">
     <b>Testing built-in $_SHS Globals:</b><br />
     <pre> <?php print_r ( $_SHS ) ; ?></pre>
   </div>
</body>
</html>
TestPHP.jpg

Disclaimer
Spigot HTTP Server is not affiliated with, or endorsed by SpigotMC Pty. Ltd. This software is provided as is, with no warranty or guarantee of it's functionality. You acknowledge you have read this disclaimer upon downloading this software.

Looking for Developers
I am looking for for partners to help expand Spigot HTTP Server into something grand. If you would like to devote time to the Spigot HTTP Server project and help getting it to a fully functioning Apache/Nginx alternative for Spigot server owners. Instead of dedicated resources to service which could have varying impact, a bundle server can be limited dynamically based on the Spigot Servers demands. This is the eventual goal. Spigot HTTP Server already runs on a cached server pool try and be as unobtrusive as possible to my knowledge.

[​IMG]
Creative Commons Attribution-NoDerivatives 4.0 International License

Commands

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Spigot HTTP Server (BETA) is a free Minecraft Java mod. Compatible with Minecraft 1.11, 1.12. Downloaded 1,005 times (via Spigot). Download it and open it directly in the game.

Explore more