Open alleywind opened 10 years ago
you can configure HAproxy to work with websockets http://blog.silverbucket.net/post/31927044856/3-ways-to-configure-haproxy-for-websockets
Working config snippet for nginx:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
[...]
location /bus {
proxy_read_timeout 999999999;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://127.0.0.1:8080;
}
I used nginx configuration which is presented above, but it didn't work for me in Google Chrome and worked in Firefox only through xhr (for websocket it returned 403). To solve this issue I've added setAllowedOrigins("http://mydomain")
to my registered endpoint:
@Configuration
@EnableScheduling
@ComponentScan("org.springframework.samples")
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/portfolio").setAllowedOrigins("http://mydomain").withSockJS();
}
...
}
See https://github.com/rstoyanchev/spring-websocket-portfolio/blob/5c898599d7fe75d2d852ac5accd2721640803726/src/main/java/org/springframework/samples/portfolio/config/WebSocketConfig.java#L36-L39 Hope, this will help to somebody :)
Hi @idelpivnitskiy , this definitely helped me, thank you :)
Is there any application like httpd or nginx which could proxy stomp protocol?