Divi WordPress Theme

Topic: Prevent direct access to specific port with nginx as reverse proxy and htaccess  (Read 3641 times)

Offline Chris

  • Junior Guru
  • **
  • Posts: 77
  • iTrader: +0/-0
    • View Profile
Hello all,

I have a website running well, listening on port 8069 (let's say mywebsite DOT com:8069)

I'd like to prevent users from accessing it directly with an htaccess for instance.

For some reason (it's an Odoo python script listening on this port), I can't directly use an htaccess file so I would like to use nginx as a reverse proxy :

[users] <---> my-nginx-proxy DOT com:80 <----> /mywebsite DOT com:8069

Is it possible to filter direct traffic on port 8069 with iptables on mywebsite.com AND allow indirect traffic from nginx reverse proxy ?
If so, how ? Since I shall then just use an htaccess on my-nginx-proxy.com

Thanks for your help
VPS Hosting - AccuWebHosting

Offline Kailash

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 663
  • iTrader: +153/-0
    • View Profile
Yes, you would use a standard nginx reverse proxy via a server + location blocks with a proxy_pass:
Code: [Select]
server {
   listen Your_SERVER_IP:80
   server_name my-nginx-proxy.com

    location /
        proxy_pass https://YOUR_IP_HERE-OR-;
        .... any additional proxy_ directives like setting headers for the host.

You can also add http authentication options or deny / allow for specific IPs or ranges. Then in iptables, restrict direct access via rules for the specific ips that you want to access it.
Shopify Divi WordPress Theme
Tags: nginx