We built node.js environment on Ubuntu server with EC2 solution of Amazon web service.
You want to use the access port as 3000, 8080, and so on, not 80.
The connection URL should then be http://XXX.XXX.XXX:80
I want to make it accessible by http://XXX.XXX.XXX.
You're referring to port forwarding, right?
port aws forwarding
General Port Forwarding
Port forwarding can be done with iptables on Linux.
It is difficult to respond flexibly to various security attacks in web technology. Therefore, I don't recommend using a web server, but the method is as follows.
iptables -t nat -A PREROUTING -ptcp -d${Local IP} --dport ${Port coming from outside} -j REDIRECT --to-port ${Port to redirect}
Here's what you're asking.
iptables -t nat -A PREROUTING -p tcp -d ${Local IP} --dport 80 -j REDIRECT --to-port 8080
Universal method for web servers
Another way is to build a Proxy server using a web server, such as nginx or apache.
For apache: Please install apache first.
First, enable the proxy module in the apache module.
# Ubuntu does the following:
$ $ a2enmod proxy proxy_http
The following are Apache settings files that need to be added:
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ProxyPreserveHostOn # Must be added to forward access domains.
Then try starting (or restarting) the apache server and accessing 80 ports. Of course, the AWS firewall and Ubuntu's own firewall must open 80 ports.
Corrective answer If you've done it with NGINX, see link .
If you see the index page of nginx, it seems that / is not treated as a proxy in the settings.
/etc/nginx/sites-available/default
server {
listen HTTP server port;
server_name domain.com;
location forwarding path {
proxy_pass http://APP_PRIVATE_IP_ADDRESS:PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Example>
server {
listen 80;
server_name domain.com;
location / {
proxy_pass http://127.0.0.1:9000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
If you do so as above, we will forward the request to http://domain.com/. If you don't have a domain yet, please use an IP accessible from the outside, or if you're not sure
listen 80;
server_name domain.com;
Instead, write it like this and try it.
listen 80 default_server;
server_name _;
And the location part in the back is important. The path following the location is the path prefix of the URL. The above example is set to /, so it's a setting for the whole.
© 2024 OneMinuteCode. All rights reserved.