Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1535

What is the best solution to redirection of HTTP to HTTPS using Boost BEAST? [closed]

$
0
0

I'm using Boost Beast as the web server in aws EC2 (Ubuntu).

I finally got https to work after a lot of trouble. http was a lot easier.

However, now I would like to be able to redirect all http (port 80) traffic to https (port 443).

I cant seem to get Beast to listen on both ports concurrently (don't mind to keep port 80 and use the secure certificates if that's possible) and if I run two separate programs, one for port 80 and the other for 443, nothing works (although they actually work by themselves).

One solution is to pay extra for it with the aws load balancer. I would like to avoid that if possible.

Another solution would be to add an extra AMI and use a simple redirection webpage (but that's extra cost also, and there might be issues with nameservers going to two different IP addresses!)

Any help much appreciated.

EDIT after ARYUEMAAN CHOWDHURY's comment:

I'm not sure specifically how. Tried it, ie tried modifying this from the main program function:

net::io_context ioc{THREADS}; //number threadsssl::context ctx{ssl::context::tlsv12};ctx.set_password_callback([](...ctx.set_options(boost::asio::ssl::context::default_workarounds | boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use);ctx.use_certificate_chain_file(....ctx.use_private_key_file(...std::make_shared<listener>(ioc, ctx, tcp::endpoint{net::ip::make_address("0.0.0.0"), PORT}, doc_root)->run(); //address = 0, port = 443std::vector<std::thread> v;v.reserve(THREADSM); //number threads - 1for(auto i = THREADSM; i > 1; --i) v.emplace_back( [&ioc] { ioc.run(); });ioc.run();

My own program is 20000 lines of pure C language, took years to complete, but frankly I'm confused with C++ (Boost Beast). How could I modify the above to create one thread for listening on port 80 and leave the rest for port 443? Again any help much appreciated...


Viewing all articles
Browse latest Browse all 1535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>