小编Joh*_*ohn的帖子

重写 - 将服务器IP转发到域url nginx

我想将我的服务器的IP重写为域名网址,但我正在努力弄清楚如何实现这一目标.

例如,当我在浏览器中输入213.34.54.xxx时,我希望将其重写为mydomain.com并且不显示IP地址.

我目前的配置如下:

/etc/nginx/nginx.conf

user www-data;
worker_processes 2;
error_log  /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  access_log /var/log/nginx/access.log;
  server_names_hash_bucket_size 64;
  sendfile        on;

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/mydomain;
}
Run Code Online (Sandbox Code Playgroud)

在/ etc/nginx的/启用的站点 - /MYDOMAIN

upstream unicorn {
    server unix:/tmp/unicorn.mydomain.sock fail_timeout=0;
   }

    server {
      listen 80 default;
      server_name localhost;
      root /home/deployer/apps/mydomain/current/public;

      location ^~ /assets/ {
        gzip_static on;
        expires max;
        add_header Cache-Control public;
      }

      try_files $uri/index.html $uri @unicorn;
      location  / {
        proxy_set_header Host $http_host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header …
Run Code Online (Sandbox Code Playgroud)

ip forwarding nginx unicorn

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

forwarding ×1

ip ×1

nginx ×1

unicorn ×1