問題描述:
nginx 配置使用80端口,自動跳轉到歡迎頁面(welcome to nginx!),但是其他端口可以正常使用
解決方法:
配置文件目錄:
/etc/nginx/sites-enables/
在這個目錄下面除了在自己寫的配置文件(×××.conf)外還有一個default文件,這個文件是默認加載的而配置文件,編輯這個default文件,打開以后是這樣的:
編輯default中的80端口,將其改為其他不經常用的端口。最后重啟nginx,nginx -s reload 即可
nginx重定向與端口映射,反向代理,外網訪問內網問題

server { listen 80; access_log /var/log/nginx/statistics_cwtc_access.log; client_max_body_size 4G; fastcgi_buffers 64 8K; client_body_buffer_size 1024k; keepalive_timeout 5; client_body_timeout 15; client_header_timeout 15; send_timeout 15; sendfile on; tcp_nopush on; tcp_nodelay on; location ~ ^/(docs|uploads|service|bms_backend|manage|system|accounts|wechat) { include uwsgi_params; uwsgi_pass uwsgi://127.0.0.1:18567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /bms-api/ { rewrite ^/bms-api/(.*) /$1 break; include uwsgi_params; uwsgi_pass uwsgi://127.0.0.1:18567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ ^/dashboard(/.*) { root /srv/lr-guomao/guomao_fe/dist; try_files $1 /index.html =404; } location ~ ^/wx(/.*) { root /srv/lr-guomao/guomao_fe/dist; try_files $1 /index.html =404; } location / { # rewrite ^/$ http://www.baidu.com redirect; # include uwsgi_params; # uwsgi_pass uwsgi://127.0.0.1:18567; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://172.16.35.253:8080; } }