I'm running ghost blog with apache front of it. I using a reverse proxy to port from 80 to local port. This is working correctly but the {{#blog.url}} tag returns hyperlink which has the local port. So once I click a link generated by #blog.url I'm having url with the local port.
How can I get rid of this?
My VirtualHost config from httpd.conf:
<VirtualHost *:80>
ServerName domain.com
ServerAlias domain.com www.domain.com
ProxyRequests Off
ProxyVia Off
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Here is my node.js ghost config.js:
// # Ghost Configuration
// Setup your Ghost install for various environments
var path = require('path'),
config;
config = {
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and emai l.
url: 'http://domain.com',
mail: {
transport: 'SMTP',
options: {
service: 'Gmail',
auth: {
user: 'email#gmail.com',
pass: 'password'
}
}
},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-dev.db')
},
debug: false
},
server: {
// Host to be passed to node's `net.Server#listen()`
host: '127.0.0.1',
// Port to be passed to node's `net.Server#listen()`, for iisnode se t this to `process.env.PORT`
port: '8080'
}
},
// ### Production
// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: 'http://my-ghost-blog.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
// Host to be passed to node's `net.Server#listen()`
host: '127.0.0.1',
// Port to be passed to node's `net.Server#listen()`, for iisnode se t this to `process.env.PORT`
port: '2368'
}
},
// **Developers only need to edit below here**
// ### Testing
// Used when developing Ghost to run tests and check the health of Ghost
// Uses a different port number
testing: {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-test.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
}
},
// ### Travis
// Automated testing run through GitHub
'travis-sqlite3': {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-travis.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
}
},
// ### Travis
// Automated testing run through GitHub
'travis-mysql': {
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'travis',
password : '',
database : 'ghost_travis',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
}
},
// ### Travis
// Automated testing run through GitHub
'travis-pg': {
url: 'http://127.0.0.1:2369',
database: {
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : '',
database : 'ghost_travis',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
}
}
};
// Export config
module.exports = config;
Related
My environment
front - windows, port 3000
backend - linux (ubuntu) in docker container, port 5000
Vue(front) tsconfig.json
export default defineConfig({
plugins: [vue(), vueJsx()],
resolve: {
alias: {
"#": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
host: true,
port: 3000,
proxy: {
"/api": {
target: "http://127.0.0.1:5000",
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
});
front api call code
const response = await axios.post("http://127.0.0.1:5000/users/login?email=" + code);
backend(Nestjs) - main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: 'http://localhost:3000',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
credentials: true,
});
await app.listen(5000);
}
bootstrap();
I expect the api call to go to the backend, localhost:5000
but i get a 404 error
When I tried with postman, I got normal return, but when I sent the request using axios in Vue with the same request, I got 404 not found.
The most incomprehensible thing is that with the current settings, it was normally requested when developing in the past.
I don't know how to fix this
please help a lot
Repositories currently being edited: https://github.com/PracticeofEno/ft_transcendence
thanks
omg... I send POST message..
But api is GET Message
I am trying following code but not working. Getting error
[ioredis] Unhandled error event: ClusterAllFailedError: Failed to
refresh slots cache.
const Redis = require("ioredis");
const cluster = new Redis.Cluster([
{
port: 6379,
host: "172.x.x.x",
},
{
port: 6379,
host: "172.x.x.x",
},
{
port: 6379,
host: "172.x.x.x",
},
], {
redisOptions: {
password: "ssffvggfg",
},
});
cluster.set("foo", "bar");
cluster.get("foo", (err, res) => {
console.log(res);
});
Thanks
The below code is working fine locally on chrome and firefox without installing the cors plugin. However, when I create a build and place a static file to a production server droplet at /var/www/html It's not working. Please let me know how to change this config file for production and I don't get cors error as well. like not getting cors or any error locally.
This is my vue.config.js file:
module.exports = {
devServer: {
proxy: {
"/one": {
target: "https://etherscan.io/",
pathRewrite: { "^/one": "" },
},
"/two": {
target: "https://bscscan.com/",
pathRewrite: { "^/two": "" },
},
},
},
};
Moreover, This is the request:
this.$http
.get("http://localhost:8080/one/token/" + this.contractAddress, {
mode: "no-cors",
header: {
"Access-Control-Allow-Origin": "http://localhost:8080/",
},
gzip: true,
})
The second request in the same component is:
this.$http
.get("http://localhost:8080/two/token/" + this.contractAddress, {
mode: "no-cors",
header: {
"Access-Control-Allow-Origin": "http://localhost:8080/",
},
gzip: true,
})
Error after deployment, when I open deployed app by IP address:
Then I tried to replace http://localhost:8080 to http//:localhost in URL and at access control allow origin I placed http://ip or server/ Then Error
So, I'm trying to figure out how to proxy to different servers with different ports and same paths.
xxx.vue:
axios.get('/actuator/health/')
.then(response => this.status = response.data.status)
.catch(err => console.log(err.message))
here is my config.vue.js :
module.exports = {
devServer: {
proxy: {
'^/actuator/': {
target: 'http://localhost:59400/',
changeOrigin: true,
secure:false,
pathRewrite: {'^/actuator': '/actuator/'},
logLevel: 'debug'
}
}
}
}
and I want to get data from port 8787 with the same path :
http://localhost:8787/actuator/health
how can I do it? if I can't change the path.
The code is on github
The following example API Proxying During development
gives an example of a proxyTable
// config/index.js
module.exports = {
// ...
dev: {
proxyTable: {
// proxy all requests starting with /api to jsonplaceholder
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}
}
}
under which they say,
The above example will proxy the request /api/posts/1 to http://jsonplaceholder.typicode.com/posts/1.
but clearly posts/1 is missing from the example.
Or should the /posts/1 be in the proxyTable or in the .vue file using axios like this,
axios.get("api/posts/1")
so that a HTTP GET request which starts with api with proxy to http://jsonplaceholder.typicode.com and then append the rest of that url, which in this case is /posts/1 and so it actually proxies to http://jsonplaceholder.typicode.com/posts/1
Is this correct?
----------EDIT FROM HERE DOWN------------
In my own case
// config/index.js
module.exports = {
// ...
dev: {
proxyTable: {
// proxy all requests starting with /conn to http://localhost:8081
'/conn': {
target: 'http://localhost:8081',
changeOrigin: true,
pathRewrite: {
'^/conn': ''
}
}
}
}
}
and
axios.get("/conn/api.php?action=read")
should proxy to,
http://localhost:8081/api.php?action=read
But I get a console error,
GET http://localhost:8080/conn/api.php?action=read 504 (Gateway Timeout)
Thanks