如何解决nginx被重定向到本地主机
我在EC2实例中遇到配置NGINX的问题。
目前我有两个网址:
http://myserver.com->显示主页http://myserver.com/admin->显示管理控制台
问题是,当我尝试访问“主页”时,它会将我重定向到计算机中的本地主机,但是当我尝试管理时,它运行良好。
这是我的/etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
server_name my.compute.amazonaws.com my.compute.amazonaws.com;
root /var/www/pro/public;
index index.php;
gzip on;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
location / {
# try to serve file directly,fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/(index|index_dev|config|install)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_buffers 64 64k;
fastcgi_buffer_size 128k;
}
location ~* ^[^(\.php)]+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ {
access_log off;
expires 1h;
add_header Cache-Control public;
}
error_log /var/log/nginx/localhost_error.log;
access_log /var/log/nginx/localhost_access.log;
}
这是/etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
我已经尝试过类似的尝试,但没有成功
proxy_redirect off;
proxy_set_header Host $http_host;
有人对此有任何线索吗?感谢您的帮助
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。