标签: httpserver

HTTP Server用于高可用性时SAML的行为

我已经实现了对SAML SSO的支持,以使我的应用程序充当使用Spring Security SAML Extension的服务提供者.我能够将我的SP与不同的国内流离失所者整合在一起.例如,我有HostA,HostB和HostC,所有这些都有我的应用程序的不同实例.我为每个主机指定了一个SP元数据文件,并使用该主机的URL设置AssertionConsumerServiceURL(EX:https:HostA.com/myapp/saml/sso).我将每个元数据文件添加到IDP并测试了所有这些文件并且工作正常.

但是,我的项目还通过配置IBM HTTP Server以实现负载平衡来支持高可用性.因此,在这种情况下,HTTP Server将主机(A,B,C)配置为用于负载平衡的主机,用户将使用HTTP服务器的URL访问我的应用程序:https:httpserver.com/myapp/

如果我定义了一个SP元数据文件并且具有在AssertionConsumerServiceURL(https://httpserver.com/saml/sso )中指定的HTTP Server的URL 并将我的实现更改为接受针对我的HTTP Server的断言,那么结果会是什么这种情况:

  1. 用户访问将用户分派给HostA的HTTPServer(幕后)
  2. HostA中的我的SP应用程序向IDP发送请求以进行身份​​验证.
  3. IDP将响应发送回我的httpserver:https: //httpserver.com/saml/sso .

HTTP服务器是否会重定向到HostA,如下所示:https: //HostA.com/saml/sso

谢谢.

high-availability saml ibmhttpserver httpserver spring-saml

4
推荐指数
1
解决办法
2363
查看次数

即使端口上没有运行任何东西,绑定地址已经在使用的golang错误

我在golang中有一个设置,它基本上从操作系统获得一个自由端口,然后在它上面启动一个http服务器.它开始出现端口注册失败的随机错误.我把它简化为以下程序,在抓住一些空闲端口后似乎出错了.它发生得非常随机,并且没有真正的进程在端口上运行它出错.对我来说,为什么这有误差是没有意义的.任何帮助,将不胜感激.

计划的输出:

..
..
58479
..
..
58867
58868
58869
..
必然好!58867
很好!58868
很好!58869
..
..
..
2015年4月28日9时05分09秒出错绑定端口:已使用的地址:听TCP:58479:绑定

我确保检查出来的自由端口从未重复过.

package main

 import (
    "net"
    "net/http"
    "log"
    "fmt"
)

func main() {

    for {
        l, _ := net.Listen("tcp", ":0")
        var port = l.Addr().String()[5:]
        l.Close()
        fmt.Println(port)
        go func() {
                l1, err := net.Listen("tcp", ":"+port)
                if (err != nil) {
                    log.Fatal("Error while binding port: ", err.Error())
                } else {
                    fmt.Println("bound well! ", port)
                }
                http.Serve(l1, nil)
            }()
    }
}
Run Code Online (Sandbox Code Playgroud)

port tcp go httpserver

4
推荐指数
2
解决办法
8142
查看次数

".htaccess"文件可以使用npm的"http-server"命令吗?

这可能是一个菜鸟问题,但是虽然npm http-server页面说明:

... http-server是一个简单的零配置命令行http服务器...

这是否意味着它完全忽略.htaccess文件?如果是这样,是否有另一个(但仍然易于使用)HTTP服务器替代方案可以读取和使用它?

.htaccess httpserver npm

4
推荐指数
1
解决办法
3055
查看次数

为什么这不是HTTP服务器在Chrome 47中为每个请求生成一个goroutine?

以前标题为:如何根据HTTP请求生成goroutine?

下面的代码是一个简单的HTTP服务器,它将路径回送给请求者.我用它来测试默认情况下包的ListenAndServe方法是否net/http触发goroutine来处理每个请求; 我发现它没有.如果我同时发出三个请求,则第一个请求返回10秒,第二个20秒(第一个返回后10秒),第三个30秒.

package main

import (
  "fmt"
  "net/http"
  "time"
)

func handler(w http.ResponseWriter, r *http.Request) {
  time.Sleep(10000 * time.Millisecond)
  fmt.Fprint(w, r.URL.Path)
}

func main() {
  http.HandleFunc("/", handler)
  http.ListenAndServe(":8080", nil)
}
Run Code Online (Sandbox Code Playgroud)

基本上我想要的是监听HTTP连接的主要goroutine,然后将请求的读取和响应传递给在另一个goroutine中生成的处理程序.

有人能指出我正确的方向来实现这个目标吗?最好net/http在go中使用包装.

更新12/21/15 08:46 AM MST

我使用我的网络浏览器(chrome 47)执行了相同的测试,在localhost的根目录下执行了五个请求:8080,结果大致如下:

1st: 10 seconds
2nd: 20 seconds
3rd: 30 seconds
4th: 36 seconds     
5th: 38 seconds
Run Code Online (Sandbox Code Playgroud)

所以,希望那些否则会对我的问题进行投票的人会理解我的困惑以及为什么我做了我的假设.我不知道为什么我得到了我在第4和第5次请求时所做的结果.

我使用curl运行相同的测试,结果与@tomasz相同.

我正在使用go1.2.1.

更新12/21/15 02:08 PM MST

根据Per tomasz的建议,我将这个问题从"如何根据每个HTTP请求生成goroutine"改为"为什么这不是用于在Chrome 47中为每个请求生成goroutine的HTTP服务器?"

concurrency go httpserver

4
推荐指数
1
解决办法
6232
查看次数

如何解决java.lang.IllegalStateException:服务器处于错误状态异常

我正在尝试在核心java项目(swing应用程序)中部署restful web-service.我正在使用jersy.我已经搜索到谷歌的许多网站,但我无法找到为什么这附加.

public class Main { 
public static void main(String[] args) throws Exception{        
    ResourceConfig resourceConfig = new ResourceConfig(MyResource.class);
    URI baseUri = UriBuilder.fromUri("http://localhost/").port(10049).build();

    HttpServer server = JdkHttpServerFactory.createHttpServer(baseUri,resourceConfig);
    server.start();
    System.out.println("Press Enter to stop the server. ");
    System.in.read();
    server.stop(0);
}
}


@Path("/hello")
public class MyResource {

// This method is called if TEXT_PLAIN is request
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
    return "Hello Jersey";
}

// This method is called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
    return "sdasd";
} …
Run Code Online (Sandbox Code Playgroud)

java rest exception-handling jersey httpserver

4
推荐指数
1
解决办法
6078
查看次数

在 Java HttpServer 响应中设置内容类型

我有一个 java echo httpserver 了。

它适用于测试站点,但我正在使用的客户端代码无法获取数据。

服务器与https://www.hurl.it/完美配合

客户端与https://requestb.in/http://httpbin.org/post完美配合

将两者结合使用时,我会收到状态代码为 200 的响应,但即使正在发送元数据/正文内容,也不会在客户端中显示。

我唯一的猜测是因为不包括内容类型,客户可能对此很挑剔。

如何在响应中指定内容类型?

(注意,客户端向服务器发送一个字符串,将 POST 作为参数以及一些标头信息。此代码当前设置为仅返回正文内容/参数。)

任何想法表示赞赏!

import static java.net.HttpURLConnection.HTTP_OK;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URLDecoder;
import java.util.List;

import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;

/**
* Echo the body of an HTTP request back as the HTTP response. This is merely
* a simple exercise of the Secret Sun Web Server. As configured, the URL to
* access …
Run Code Online (Sandbox Code Playgroud)

java outputstream httpserver server

4
推荐指数
1
解决办法
6113
查看次数

Apache ProxyPass 负载平衡所有 URL

使用 Apache HTTP Server,如何对所有 URL 进行负载平衡,而不仅仅是根“/”或根下的一些子目录(如“/css”),而是绝对平衡后端的所有内容?

我的配置只会路由文字根 URL“/”,但不涵盖其他 URL,我需要使用正则表达式吗?

相关配置:

<Proxy balancer://mycluster>
    BalancerMember https://server1:8443
    BalancerMember https://server2:8443
    ProxySet lbmethod=byrequests
</Proxy>

<VirtualHost _default_:443>
    SSLProxyEngine on
    ProxyPass "/" "balancer://mycluster"
    ProxyPassReverse "/" "balancer://mycluster"
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

Apache access_log(注意 /css 收到 500 响应):

172.18.0.1 - - [10/May/2017:20:22:55 +0000] "GET / HTTP/1.1" 200 196
172.18.0.1 - - [10/May/2017:20:22:58 +0000] "GET /css HTTP/1.1" 500 528
Run Code Online (Sandbox Code Playgroud)

阿帕奇错误日志:

[Wed May 10 20:22:58.607433 2017] [proxy:warn] [pid 9:tid 140682836559616] [client 172.18.0.1:35304] AH01144: No protocol handler was valid for the URL /css. If you …
Run Code Online (Sandbox Code Playgroud)

apache http httpd.conf httpserver

4
推荐指数
1
解决办法
1274
查看次数

如何在nodejs中下载http网站服务器上托管的文件

我创建了一个nodejs http webserver来托管一些文件 -

 var http = require('http'),
    fs = require('fs');

var finalhandler = require('finalhandler');
var serveStatic = require('serve-static');
var qs = require('querystring');
var serve = serveStatic("./");
fs.readFile('./index.html', function (err, html) {
    if (err) {
        throw err; 
    }       
    http.createServer(function(req, res) {  
        var done = finalhandler(req, res);
        serve(req, res, done);
    if(req.method === "POST") {
           if (req.url === "/downloadInstaller") {
              var requestBody = '';
              req.on('data', function(data) {
                requestBody += data;
                if(requestBody.length > 1e7) {
                  res.writeHead(413, 'Request Entity Too Large', {'Content-Type': 'text/html'});
                  res.end('<!doctype …
Run Code Online (Sandbox Code Playgroud)

html http-post httpserver node.js

4
推荐指数
1
解决办法
196
查看次数

单页应用程序的简单命令行 http 服务器

有各种单行 HTTP 服务器命令,例如最著名的可能是python -m http.server. 我正在寻找一个类似的命令,该命令将运行一个忽略文件路径并将所有路径发送到特定文件的服务器,例如,如果您访问 /foo 或 /bar,它将从index.html.

理想情况下,对于典型的 Linux/MacOS 机器,尽可能少安装麻烦。(例如,pythonhttp.server对许多用户来说都是开箱即用的。)

它与 htaccess rule 提供的功能相同RewriteRule (.*) /index.html,但不需要设置 Apache。不确定这些单行服务器中是否有任何支持类似的东西,比如一个命令行参数,它会为所有路径声明默认文件。

command-line http httpserver single-page-application

4
推荐指数
1
解决办法
1549
查看次数

支持简历的Indy Http Server

我写了一个indy http服务器,我想用简历支持服务文件下载.当我使用IDM下载文件时,下载是单线程的:

在此输入图像描述

请注意," 恢复"功能"",但是当我暂停并恢复下载时,它将从表单开始.

我的Indy Http服务器如下:

void __fastcall TfrmMain::httpServerCommandGet(TIdContext *AContext,
    TIdHTTPRequestInfo *ARequestInfo, TIdHTTPResponseInfo *AResponseInfo)
{
    Beep(1000, 100);
    string fileName = ExtractFileDir(Application->ExeName) + ARequestInfo->Document;
    fileName = fileName.replace("/", "\\");

    TFileStream *stream = new TFileStream(fileName, fmOpenRead | fmShareDenyNone);

    int start = 0, end = 0;
    string range = ARequestInfo->Range;
    if(!range.empty())
    {
        int dash_pos = range.find("-");
        start = range.substr(0, dash_pos).intValue();
        end = range.substr(dash_pos + 1).intValue();
        if(end == 0) // Endless Range: start-
            end = stream->Size;
    }
    else
    {
        start …
Run Code Online (Sandbox Code Playgroud)

delphi tcp indy c++builder httpserver

3
推荐指数
1
解决办法
1327
查看次数