所以我在Docker容器中运行了一个Nginx,我在localhost上运行了一个mysql,我想从我的Nginx中连接到MySql.MySql在localhost上运行,而不是将端口暴露给外部世界,所以它绑定在localhost上,而不是绑定在机器的ip地址上.
有没有办法从这个docker容器中连接到这个MySql或localhost上的任何其他程序?
我在我的服务器上设置了Node.js和Nginx.现在我想使用它,但是,在我开始之前有2个问题:
Node.js服务器有2个概念,其中一个更好:
一个.为需要它的每个网站创建单独的HTTP服务器.然后在程序开始时加载所有JavaScript代码,因此代码被解释一次.
湾 创建一个处理所有Node.js请求的Node.js服务器.这将读取所请求的文件并篡改其内容.因此,每个请求都会解释文件,但服务器逻辑要简单得多.
我不清楚如何正确使用Node.js.
我在Rackspace云上使用nginx跟随一个教程并搜索网络,到目前为止无法对此进行排序.
我希望www.mysite.com在.htaccess中正常访问mysite.com以获取SEO和其他原因.
我的/etc/nginx/sites-available/www.example.com.vhost配置:
server {
listen 80;
server_name www.example.com example.com;
root /var/www/www.example.com/web;
if ($http_host != "www.example.com") {
rewrite ^ http://example.com$request_uri permanent;
}
Run Code Online (Sandbox Code Playgroud)
我也试过了
server {
listen 80;
server_name example.com;
root /var/www/www.example.com/web;
if ($http_host != "www.example.com") {
rewrite ^ http://example.com$request_uri permanent;
}
Run Code Online (Sandbox Code Playgroud)
我也试过了.第二次尝试都会给出重定向循环错误.
if ($host = 'www.example.com' ) {
rewrite ^ http://example.com$uri permanent;
}
Run Code Online (Sandbox Code Playgroud)
我的DNS设置为标准:
site.com 192.192.6.8 A type at 300 seconds
www.site.com 192.192.6.8 A type at 300 seconds
Run Code Online (Sandbox Code Playgroud)
(示例IP和文件夹已用于示例,并在将来帮助人们).我使用的是Ubuntu 11.
我需要通过我的应用服务器提供我的应用程序8080,以及来自目录的静态文件,而无需触及应用服务器.我拥有的nginx配置是这样的......
# app server on port 8080
# nginx listens on port 8123
server {
listen 8123;
access_log off;
location /static/ {
# root /var/www/app/static/;
alias /var/www/app/static/;
autoindex off;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,使用此配置,一切正常.请注意,该root指令已被注释掉.
如果我激活root和停用alias- 它会停止工作.但是,当我/static/从root它删除尾随它开始再次工作.
有人可以解释发生了什么.还请解释清楚和冗长之间有什么区别root和alias和它们的用途.
我正在使用django和fastcgi + nginx.我想知道在这种情况下存储日志(错误)的位置
我以前使用过Apache,所以我知道默认的公共Web根目录通常是/var/www/.
我最近开始使用nginx,但我似乎无法找到默认的公共Web根目录.
我在哪里可以找到nginx的默认公共Web根目录?
我将nginx更新为1.4.7,将php 更新为5.5.12,之后我得到了502错误.在我更新之前一切正常.
nginx的-error.log中
2014/05/03 13:27:41 [crit] 4202#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xx.xxx.xx.xx, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xx.xx.xx.xx"
Run Code Online (Sandbox Code Playgroud)
nginx.conf
user www www;
worker_processes 1;
location / {
root /usr/home/user/public_html;
index index.php index.html index.htm;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/home/user/public_html$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用nginx和gunicorn配置django项目.当我gunicorn mysite.wsgi:application --bind=127.0.0.1:8001在nginx服务器中访问我的端口时,我在错误日志文件中收到以下错误.
server {
listen 8080;
server_name localhost;
access_log /var/log/nginx/example.log;
error_log /var/log/nginx/example.error.log;
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
}
}
Run Code Online (Sandbox Code Playgroud)
我的"http://127.0.0.1:8001/"档案
server {
listen 8080;
server_name localhost;
access_log /var/log/nginx/example.log;
error_log /var/log/nginx/example.error.log;
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
}
}
Run Code Online (Sandbox Code Playgroud)
在我得到的html页面中nginx.conf.
我做错了什么?
我使用nginx作为前端服务器,我修改了CSS文件,但是nginx仍在服务旧的.
我试图重新启动nginx,没有成功,我有谷歌搜索,但没有找到一个有效的方法来清除它.
有些文章说我们可以删除缓存目录:var/cache/nginx但是我的服务器上没有这样的目录.
我现在应该怎么做?
突然间,我得到了以下nginx错误
* Restarting nginx
* Stopping nginx nginx
...done.
* Starting nginx nginx
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
...done.
...done.
Run Code Online (Sandbox Code Playgroud)
如果我跑
lsof -i :80 …Run Code Online (Sandbox Code Playgroud)