By iburnthings
Ubuntu Desktop 16.04 LTS, running on Hyper-V on windows 10 pro x64 I have two wordpress sites, one is on port 80 with server_name directive pointing to root The other is running on port 8001. I don’t remember why I configured it this way but I’m ok with changing it. The problem seems to be that even though I have all the ports open I have to login to ubuntu before the firewall rule kicks in . My port 80 site works fine but the 8001 gives chrome a sad page icon until after the login.
[02/11/2017 12:25:50 AM] Status: Enabled
[02/11/2017 12:25:37 AM] Status: Disabled
[02/11/2017 12:25:20 AM] Status: Enabled
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 81 > Skipping adding existing rule | Skipping adding existing rule (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 8001 > Skipping adding existing rule | Skipping adding existing rule (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 81 > Rule added | Rule added (v6)
[02/10/2017 07:35:52 AM] Appending new rules: ufw allow in 8001 > Rule added | Rule added (v6)
[02/10/2017 07:35:52 AM] Deleting previous rules: 3 ufw --force delete 3 > Rule deleted
[02/10/2017 07:35:52 AM] Deleting previous rules: 6 ufw --force delete 6 > Rule deleted (v6)
[02/10/2017 07:35:51 AM] Status: Enabled
[02/10/2017 07:35:50 AM] Changing profile: Public
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
What I would recommend doing, just to make sure we get the correct setup, is running
ufw disable
Then
ufw reset
The above stops ufw
and then resets all rules. With a clean slate, we setup our default policies first.
ufw default deny incoming \
&& ufw default allow outgoing
With those rules in place, we then add the rules we need to work for whatever our purposes are. To start, I recommend allowing SSH in first.
ufw allow 22/tcp
We can then allow application-specific ports, such as 80, 443, 8001, etc. I’ll start with those three.
ufw allow 80/tcp \
&& ufw allow 443/tcp \
&& ufw allow 8001/tcp
We could also run just one command (copy and paste directly)
ufw disable \
&& ufw reset \
&& ufw default deny incoming \
&& ufw default allow outgoing \
&& ufw allow 22/tcp \
&& ufw allow 80/tcp \
&& ufw allow 443/tcp \
&& ufw allow 8001/tcp
Now, if you need to add any other ports, now’s the time to go ahead and add them. If nothing more needs to be added, we can then run
ufw enable
When prompted to confirm, type y
, hit enter, and ufw
is active once again.
The benefit to the above is outgoing connections are always allowed, though only the ports you define are permitted to connect (i.e. incoming).
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.