search

Home  >  Q&A  >  body text

nginx non-port 80 virtual host

Excuse me, my nginx can only run on non-80 ports
So how do I forward the domain name to this non-80 port
For example, as follows:

    listen 8000;
    server_name  abc.test www.abc.test;

    location / {
            root /home/www/abc.test;
            index index.html index.htm;

            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $http_host;

            if ($http_host = "www.abc.test") {
                     proxy_pass http://127.0.0.1:8000;
            }

            if ($http_host = "abc.test") {
                    proxy_pass http://127.0.0.1:8000;
            }
習慣沉默習慣沉默2753 days ago526

reply all(2)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-16 17:22:42

    If your Nginx is listening on port 8000, then you need to find a way to forward port 80, similar to:

    iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:22:42

    If there is no registration, just set up an off-wall server and then link to 8000 through nginx

    reply
    0
  • Cancelreply