Hi I am trying to run a vibe.d serve on google compute cloud.
The machine instance is:
Machine type n1-standard-1
CPU platform Intel Skylake
Architecture x86/64
vCPUs to core ratio —
Custom visible cores —
Display device Disabled
GPUs None
I have assigned a static IP using network interfaces where type is default, and external IP is a static IP. Both HTTP and HTTPS traffics are allowed.
Under VPC Network > firewall rules, I have created a new rule:
Network default
Priority 1000
Direction Ingress
Action on match Allow
Source filters
IP ranges 0.0.0.0/0
Protocols and ports
tcp:8080
Enforcement Enabled
Now, I created a dub project with sudo rights. The app.d is like this:
import vibe.vibe;
void main()
{
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = ["::", "MY.SERVERS.STATIC.IP"]; // tested with this line commented out, and with ::1
auto listener = listenHTTP(settings, &hello);
scope (exit)
{
listener.stopListening();
}
logInfo("Please open http://127.0.0.1:8080/ in your browser.");
runApplication();
}
void hello(HTTPServerRequest req, HTTPServerResponse res)
{
res.writeBody("Hello, World!");
}
i run with dub run. This leads to:
[main(----) INF] Listening for requests on http://[::]:8080/
Failed to listen on MY.SERVERS.STATIC.IP:8080
[main(----) INF] Please open http://127.0.0.1:8080/ in your browser.
Vibe was run as root, and no user/group has been specified for privilege lowering. Running with full permissions.
netstat | grep 8080 returns nothing.
Note, that if i replace MY.SERVERS.STATIC.IP with 0.0.0.0, and keep ::1, then although i get:
[main(----) INF] Listening for requests on http://[::1]:8080/
[main(----) INF] Listening for requests on http://0.0.0.0:8080/
[main(----) INF] Please open http://127.0.0.1:8080/ in your browser.
Vibe was run as root, and no user/group has been specified for privilege lowering. Running with full permissions.
The server remains unreachable. I can ping, but calling with firefox or chrome with port number returns a 404 error.
What can I do to run a vibe.d server on google cloud? Thank you
Related
In my local development setup, I'm using Django as the webserver (a-la python manage.py runserver 8000) and I'm able to kubectl port-forward <django_pod> 8000 my traffic to my local dev machine so I can interact with my site by browsing to http://localhost:8000/testpage. I've configured my ALLOWED_HOSTS to include localhost to enable this.
However, I'd like to avoid using port-forward and go the more proper route of running my traffic through the Kubernetes ingress controller and service. On the same Minikube cluster, I have ingress configured to point certain traffic urls to a very rudimentary nginx pod to confirm that my ingress+service+pod networking is working properly. All other urls should route to my Django app. The only difference is the nginx traffic is all on port 80.
In my ingress controller logs, I can see the traffic being sent to the k8s service for my Django app:
192.168.64.1 - [192.168.64.1] - - [22/Nov/2019:03:50:52 +0000] "GET /testpage HTTP/2.0" 502 565 "-" "browser" 24 0.002 [default-django-service-8000] [] 172.17.0.5:8000, 172.17.0.5:8000, 172.17.0.5:8000 0, 0, 0 0.000, 0.000, 0.000 502, 502, 502 aa2682896e4d7a2052617f7d12b1a02b
When I look at the Django logs, I don't see any traffic hitting it.
My ingress servicePort is 8000, the django-service port is 8000 (I've just let it default to ClusterIP), the pod's spec.containers.ports.containerPort is 8000, and the process has been set to listen on port 8000 as I mentioned before.
When I check kubectl get endpoints, it correctly shows me an endpoint is connected on port 8000 (and it correctly changes to the new pods' IPs when I restart them).
I've used the following guides to try to debug:
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/
https://medium.com/#ManagedKube/kubernetes-troubleshooting-ingress-and-services-traffic-flows-547ea867b120
My guess is it might be a problem with ALLOWED_HOSTS but I added a * wildcard to the list and it's still not working.
What is wrong with my setup?
You need to instruct the server to listen on all interfaces by running python manage.py runserver 0.0.0.0:<port>.
Django's runserver listens on the local loopback interface (localhost/127.0.0.1) by default so, if you run python manage.py runserver 8000, you can can only reach the server on port 8000 from the machine on which the server is running.
There is a lot of documentation around this, but here are just a couple examples:
About IP 0.0.0.0 in Django
http://www.holeintheceiling.com/blog/2012/06/21/django-and-runserver-0-0-0-0/
I have a google cloud compute engine instance with Ubuntu 16.04 on it. I have a flask app running on port 5000.
I've set up firewall rules to allow ingress traffic for any host (using 0.0.0.0/0 filter) for tcp:5000. I ran the
sudo ufw allow 5000
command on the console.
At this point I was expecting to see the flask app by entering http://external_ip:5000 on my browser. But that is not the case. I get "external_ip refused to connect." error on the browser. What am I doing wrong?
Its working if I run the flask app on port 80 though.
As the allow-internal rule is active in the firewall rules. I thought maybe try accessing from a node under the same project (thus same default network). But no luck.
I had the same problem. The way to fix is, to add host parameter to Flask app as shown below. By default Flask App is designed to work on localhost only. This has fixed the problem for me
if __name__ == '__main__':
app.run(debug=False, port=8081, host='0.0.0.0')
I bought a domain name using amazon Route 53, created an elastic IP address and attached it to my Amazon EC2 instance running MEAN bitnami stack, then I created an S3 bucket for static web hosting "redirecting all requests" to the www.domainname.com.
However, when I go to my root domain the page loaded is the Bitnami Congratulations page: You are now running Bitnami MEAN 3.2.11-0 in the Cloud. I created a folder, uploaded my MEAN angular 2/express app and did node server.js and I can only access my web app on mydomain.com:8080 but anything else redirects to the Bitnami congratulations page. Which setting is it that is doing this? Is it an amazon setting? A Bitnami setting? or something in my server side code.
The only place I mention 8080 in my server code is here and it prints API running on 8080 when I run the server:
const port = process.env.PORT || '8080';
app.set('port', port);
const server = http.createServer(app);
server.listen(port, () => console.log(`API running on: ${port}` + ' or ' + process.env.PORT));
You have Apache running on your MEAN Stack. Apache is running on port 80/443 and, therefore, whenever you access your domain at port 80, Apache handle the request and shows you the "Bitnami Welcome Page".
In order to make your Angular/express application available at port 80 you need to configure Apache to redirect the requests to port 3000 (or port 8080, basically the port where your Express application is running). You could add under <VirtualHost _default_:80> and <VirtualHost _default_:443> sections in the file /opt/bitnami/apache2/conf/bitnami/bitnami.conf the line below:
ProxyPass /bitnami !
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
After that, you will need to restart Apache running:
sudo /opt/bitnami/ctlscript.sh restart apache
You can find more information at:
https://docs.bitnami.com/aws/infrastructure/mean/
Bitnami by default launches with an http config here: root/opt/apache2/conf/httpd.conf. The apache2 server pointed at a root directory containing html with an index.html that contains its Congratulations page. Using sudo /opt/bitnami/ctlscript.sh stop killed this server and all other services it had running by default on startup so when I type node server.js all traffic now goes to my Angular 2 app.
Use NGINX to reverse proxy all trafic from http://www.domainname.com to address where your node server is running ( http://localhost:8080).
Here is the sample NGINX configuration for such a use case.
To install NGINX follow one of tutorials on digitalocean.com depending upon your server OS.
I'm trying to deploy a very simple Spring Boot application on AWS Elastic Beanstalk using AWS's Java configuration (not their Tomcat configuration), but I keep getting a 502 error with the following log:
2016/06/10 02:00:14 [error] 4921#0: *1 connect() failed
(111: Connection refused) while connecting to upstream, client: 38.94.153.178,
server: , request: "GET /test HTTP/1.1", upstream: "http://127.0.0.1:5000/test",
host: "my-single-instance-java-app.us-east-1.elasticbeanstalk.com"
I've tried setting my port via Spring's application.properties to what the log seems to want (5000, using server.port=5000) and have verified that my application runs successfully on that port on localhost.
This question is very similar, except that I'm deploying a JAR instead of a WAR. It seems like there is something I'm missing regarding configuring Nginx, and I don't know how to proceed.
Here's my Spring Application:
#SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
#RestController
public static class MainController {
#RequestMapping("/test")
public String testMethod() {
return "Method success!";
}
}
}
Nginx doesn't know on which port your spring boot applicaiton is running.
Make application run on port 5000 that Nginx redirects to by default by adding "server.port=5000" to application.properties or other suggested ways in the last step:
https://pragmaticintegrator.wordpress.com/2016/07/12/run-your-spring-boot-application-on-aws-using-elastic-beanstalk/
From your question description and the security group settings you send me your only inbound Port 80 for your EC2 instance was open to world through firewall and you were using port 5000 for your application. So using the security rule that I gave you it opened the inbound port 5000 too for your EC2 instance so your application started working without above error.
If somebody is still getting such error, after setting server.port=5000.
Here's what you can do if you got db connectivity:
In configuration section of your dashboard, go to RDS section and create a remote db. Remember username, password of formed db.
In Software section, add following properties:
SPRING_DATASOURCE_URL=jdbc:mysql://(your-db-url)/ebdb
SPRING_DATASOURCE_USERNAME=(username)
SPRING_DATASOURCE_PASSWORD=(password)
SPRING_JPA_HIBERNATE_DDL_AUTO=update
SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.MySQL5Dialect
After reading both eb-engine.log as well nginx/error.log, the default nginx port is 5000 whereas the default port for spring-boot is 8080.
We can update our application via the elastic beanstalk CLI with the setenv cmd.
eb setenv SERVER_PORT=5000
We can update this in the code via application.properties
server.port=5000
These steps worked for me,
Go-To > Environments > Select your environment,
Select "Configuration" at the left
Click on "Edit" against Software
Scroll Down to "Environment Properties"
add one more entry SERVER_PORT and set some number, I set 5000
I installed node.js on a hosted Apache server. The simple server I placed on the server runs fine, but when I go to the website I cannot see the website.
I initially tested this on my local machine and it works fine, but I need this on a production website. How can I do this.
My Node.js code
[code]
// Load the net module to create a tcp server.
var net = require('net');
// Setup a tcp server
var server = net.createServer(function (socket) {
// Every time someone connects, tell them hello and then close the connection.
socket.addListener("connect", function () {
sys.puts("Connection from " + socket.remoteAddress);
socket.end("Hello World\n");
});
});
// Fire up the server bound to port 7000 on localhost
server.listen(1337, "localhost");
[/code]
// Put a friendly message on the terminal
console.log("TCP server listening on port 1337 at localhost.");
Then I run node test.js
Response : TCP server listening on port 1337 at localhost.
Then I go to www.mywebsite.com:1337
Oops! Google Chrome could not connect to www.mywebsite.com:1337
So I tried using the actual IP
server.listen(1337, "xx.xx.xx.xx");
And the URL
server.listen(1337, "http://mywebsite.com");
// this actually broke the server immediatly
So how can I do this?
You will need a firewall rule to allow incoming traffic.
iptables -A INPUT -p tcp --dport 1337 -j ACCEPT
and do not bind to localhost, but on the port only:
server.listen(1337/*, "localhost"*/);
http://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback
EDIT: This comments out the host, so your server will listen on all adresses (this is the same as:)
server.listen(1337);
If you still encounter problems, this is most likely a firewall problem.